From af84ef2bc0b41c029ab1f8f589b4cf25c90331c1 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Mon, 19 Sep 2011 19:57:35 +0800 Subject: Fix 5337270: Thumbnail is not generated for large GIF images. Change-Id: I8e2e8cafb01b2289f59b28b7e2eadae3dc5c0c50 --- .../src/com/android/gallery3d/common/BitmapUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gallerycommon/src/com/android/gallery3d/common') diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java index 060d7f32e..c34e89631 100644 --- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java +++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java @@ -155,6 +155,17 @@ public class BitmapUtils { return resizeBitmapByScale(bitmap, scale, recycle); } + // Resize the bitmap if each side is >= targetSize * 2 + public static Bitmap resizeDownIfTooBig( + Bitmap bitmap, int targetSize, boolean recycle) { + int srcWidth = bitmap.getWidth(); + int srcHeight = bitmap.getHeight(); + float scale = Math.max( + (float) targetSize / srcWidth, (float) targetSize / srcHeight); + if (scale > 0.5f) return bitmap; + return resizeBitmapByScale(bitmap, scale, recycle); + } + // Crops a square from the center of the original image. public static Bitmap cropCenter(Bitmap bitmap, boolean recycle) { int width = bitmap.getWidth(); -- cgit v1.2.3