Skip to content
Permalink
Browse files
Merge pull request #9944 from JosJuice/android-nonsquare-buttons
Android: Allow non-square overlay control images
  • Loading branch information
JosJuice committed Dec 11, 2022
2 parents cac5d0b + 3accb06 commit 82e87cf
Showing 1 changed file with 6 additions and 3 deletions.
@@ -106,11 +106,14 @@ public static Bitmap resizeBitmap(Context context, Bitmap bitmap, float scale)
// Determine the button size based on the smaller screen dimension.
// This makes sure the buttons are the same size in both portrait and landscape.
DisplayMetrics dm = context.getResources().getDisplayMetrics();
int minDimension = Math.min(dm.widthPixels, dm.heightPixels);
int minScreenDimension = Math.min(dm.widthPixels, dm.heightPixels);

int maxBitmapDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
float bitmapScale = scale * minScreenDimension / maxBitmapDimension;

return Bitmap.createScaledBitmap(bitmap,
(int) (minDimension * scale),
(int) (minDimension * scale),
(int) (bitmap.getWidth() * bitmapScale),
(int) (bitmap.getHeight() * bitmapScale),
true);
}

0 comments on commit 82e87cf

Please sign in to comment.