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

Commit f12a5c23 authored by Sumedh Sen's avatar Sumedh Sen Committed by Android (Google) Code Review
Browse files

Merge "Recycle the original bitmap after scaling down" into main

parents 4567f3a2 74d9576b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class PackageUtil {

        private Bitmap getBitmapFromDrawable(Drawable drawable) {
            // Create an empty bitmap with the dimensions of our drawable
            Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            final Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                    drawable.getIntrinsicHeight(),
                    Bitmap.Config.ARGB_8888);
            // Associate it with a canvas. This canvas will draw the icon on the bitmap
@@ -183,7 +183,11 @@ public class PackageUtil {

            // Scale it down if the icon is too large
            if ((bmp.getWidth() > iconSize * 2) || (bmp.getHeight() > iconSize * 2)) {
                bmp = Bitmap.createScaledBitmap(bmp, iconSize, iconSize, true);
                Bitmap scaledBitmap = Bitmap.createScaledBitmap(bmp, iconSize, iconSize, true);
                if (scaledBitmap != bmp) {
                    bmp.recycle();
                }
                return scaledBitmap;
            }
            return bmp;
        }