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

Commit c32dd5f2 authored by Chih-Chung Chang's avatar Chih-Chung Chang
Browse files

Fix 3274309: Returns correctly sized thumbnails for MINI_KIND video thumbnails.

Change-Id: I88b293e44430eebe780dfb9eb06d80f8ce89483f
parent 36f43908
Loading
Loading
Loading
Loading
+16 −2
Original line number Original line Diff line number Diff line
@@ -160,7 +160,21 @@ public class ThumbnailUtils {
                // Ignore failures while cleaning up.
                // Ignore failures while cleaning up.
            }
            }
        }
        }
        if (kind == Images.Thumbnails.MICRO_KIND && bitmap != null) {

        if (bitmap == null) return null;

        if (kind == Images.Thumbnails.MINI_KIND) {
            // Scale down the bitmap if it's too large.
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            int max = Math.max(width, height);
            if (max > 512) {
                float scale = 512f / max;
                int w = Math.round(scale * width);
                int h = Math.round(scale * height);
                bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
            }
        } else if (kind == Images.Thumbnails.MICRO_KIND) {
            bitmap = extractThumbnail(bitmap,
            bitmap = extractThumbnail(bitmap,
                    TARGET_SIZE_MICRO_THUMBNAIL,
                    TARGET_SIZE_MICRO_THUMBNAIL,
                    TARGET_SIZE_MICRO_THUMBNAIL,
                    TARGET_SIZE_MICRO_THUMBNAIL,