diff options
| author | 2018-11-19 18:25:34 +0800 | |
|---|---|---|
| committer | 2018-11-20 22:38:08 +0800 | |
| commit | a358d7611ccf1a2a55da137ef3f8067ebac154e2 (patch) | |
| tree | bd19e000196f0407251b6f6d050c539debd50f30 | |
| parent | 24efb38c077b921726b99320b822655ab1909b70 (diff) | |
Set minimum scaled width/height to 1
Applications could be launched on a secondary display that
has lower density than default display. While some applications
may use 1x1 image resource as activity background, the scaled
width/height would be 0 if down scaling the 1x1 image with
scale ratio that is less than 1/2.
Making sure the scaled width/height won’t less than 1 to
prevent application crashed.
Bug: 117749148
Test: Launch app on secondary display
Change-Id: I73567dd237736466d0bc423485359d50073d86c1
| -rw-r--r-- | graphics/java/android/graphics/ImageDecoder.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/ImageDecoder.java b/graphics/java/android/graphics/ImageDecoder.java index 009e042f74a7..e3b165ccaf34 100644 --- a/graphics/java/android/graphics/ImageDecoder.java +++ b/graphics/java/android/graphics/ImageDecoder.java @@ -1869,8 +1869,8 @@ public final class ImageDecoder implements AutoCloseable { } float scale = (float) dstDensity / srcDensity; - int scaledWidth = (int) (mWidth * scale + 0.5f); - int scaledHeight = (int) (mHeight * scale + 0.5f); + int scaledWidth = Math.max((int) (mWidth * scale + 0.5f), 1); + int scaledHeight = Math.max((int) (mHeight * scale + 0.5f), 1); this.setTargetSize(scaledWidth, scaledHeight); return dstDensity; } |