コード例 #1
0
 private static Insets scaleFromDensity(Insets insets, int sdensity, int tdensity) {
   int left = Bitmap.scaleFromDensity(insets.left, sdensity, tdensity);
   int top = Bitmap.scaleFromDensity(insets.top, sdensity, tdensity);
   int right = Bitmap.scaleFromDensity(insets.right, sdensity, tdensity);
   int bottom = Bitmap.scaleFromDensity(insets.bottom, sdensity, tdensity);
   return Insets.of(left, top, right, bottom);
 }
コード例 #2
0
 private void computeBitmapSize() {
   final int sdensity = mNinePatch.getDensity();
   final int tdensity = mTargetDensity;
   if (sdensity == tdensity) {
     mBitmapWidth = mNinePatch.getWidth();
     mBitmapHeight = mNinePatch.getHeight();
     mOpticalInsets = mNinePatchState.mOpticalInsets;
   } else {
     mBitmapWidth = Bitmap.scaleFromDensity(mNinePatch.getWidth(), sdensity, tdensity);
     mBitmapHeight = Bitmap.scaleFromDensity(mNinePatch.getHeight(), sdensity, tdensity);
     if (mNinePatchState.mPadding != null && mPadding != null) {
       Rect dest = mPadding;
       Rect src = mNinePatchState.mPadding;
       if (dest == src) {
         mPadding = dest = new Rect(src);
       }
       dest.left = Bitmap.scaleFromDensity(src.left, sdensity, tdensity);
       dest.top = Bitmap.scaleFromDensity(src.top, sdensity, tdensity);
       dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity);
       dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity);
     }
     mOpticalInsets = scaleFromDensity(mNinePatchState.mOpticalInsets, sdensity, tdensity);
   }
 }