mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 04:38:49 +00:00
Android: Allow non-square overlay control images
This removes an assumption in the code which made every overlay control image be scaled to a square even if the actual image was rectangular.
This commit is contained in:
parent
f380c23fda
commit
3accb06fe1
1 changed files with 6 additions and 3 deletions
|
@ -102,11 +102,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||||
// Determine the button size based on the smaller screen dimension.
|
// Determine the button size based on the smaller screen dimension.
|
||||||
// This makes sure the buttons are the same size in both portrait and landscape.
|
// This makes sure the buttons are the same size in both portrait and landscape.
|
||||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
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,
|
return Bitmap.createScaledBitmap(bitmap,
|
||||||
(int) (minDimension * scale),
|
(int) (bitmap.getWidth() * bitmapScale),
|
||||||
(int) (minDimension * scale),
|
(int) (bitmap.getHeight() * bitmapScale),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue