Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a358d761 authored by Louis Chang's avatar Louis Chang
Browse files

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
parent 24efb38c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
    }