diff options
| author | JosJuice <josjuice@gmail.com> | 2021-07-23 13:04:16 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2021-07-23 13:16:27 +0200 |
| commit | 3accb06fe1ae18b0769bca2cb4f93be1ff3ee6e7 (patch) | |
| tree | 95984638010047757c47fa74c6c0e7b7f15d600c /Source/Android/app/src | |
| parent | f380c23fda9fd1b45e458551a8dd1aa9ae60db0a (diff) | |
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.
Diffstat (limited to 'Source/Android/app/src')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java index 5b3b232af4..1e7cb81b77 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java @@ -102,11 +102,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // 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); } |
