diff options
| author | Chih-Chung Chang <chihchung@google.com> | 2011-09-19 19:57:35 +0800 |
|---|---|---|
| committer | Chih-Chung Chang <chihchung@google.com> | 2011-09-20 10:15:58 +0800 |
| commit | 6c8d0fd879242f78a0c1a7daf4c037043663a49f (patch) | |
| tree | ee817a636329edfa50f1d0e48b45a2612757e75d /gallerycommon/src/com | |
| parent | 5da31f8fd85d7c1e33133473bd1fbc5e3a240f2d (diff) | |
| download | android_packages_apps_Gallery2-6c8d0fd879242f78a0c1a7daf4c037043663a49f.tar.gz android_packages_apps_Gallery2-6c8d0fd879242f78a0c1a7daf4c037043663a49f.tar.bz2 android_packages_apps_Gallery2-6c8d0fd879242f78a0c1a7daf4c037043663a49f.zip | |
Fix 5337270: Thumbnail is not generated for large GIF images.
Change-Id: I8e2e8cafb01b2289f59b28b7e2eadae3dc5c0c50
Diffstat (limited to 'gallerycommon/src/com')
| -rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java | 11 |
1 files changed, 11 insertions, 0 deletions
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(); |
