diff options
| author | Sascha Haeberling <haeberling@google.com> | 2012-10-24 18:35:37 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-24 18:42:19 -0700 |
| commit | 044513931d31a4b86f622b1af36e9ce947672be7 (patch) | |
| tree | 7e7b38ebe8e9abae88bc625ecd94d0577dfa3e37 /src/com | |
| parent | 2c6ea941a80ea22317d664e329aed51f5f7417b9 (diff) | |
| download | android_packages_apps_Gallery2-044513931d31a4b86f622b1af36e9ce947672be7.tar.gz android_packages_apps_Gallery2-044513931d31a4b86f622b1af36e9ce947672be7.tar.bz2 android_packages_apps_Gallery2-044513931d31a4b86f622b1af36e9ce947672be7.zip | |
Fixes TinyPlanet crashed due to too excessive memory usage.
Bug: 7409664
Change-Id: If82882ce7186500f5a3af769d490275233a6191c
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java index d5efe46f1..7ec136766 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java @@ -18,7 +18,7 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Rect; +import android.graphics.RectF; import com.adobe.xmp.XMPException; import com.adobe.xmp.XMPMeta; @@ -74,11 +74,11 @@ public class ImageFilterTinyPlanet extends ImageFilter { public Bitmap apply(Bitmap bitmapIn, float scaleFactor, boolean highQuality) { int w = bitmapIn.getWidth(); int h = bitmapIn.getHeight(); - int outputSize = Math.min(w, h); + int outputSize = (int) (w / 2f); ImagePreset preset = getImagePreset(); if (preset != null && preset.isPanoramaSafe()) { - bitmapIn = applyXmp(bitmapIn, preset); + bitmapIn = applyXmp(bitmapIn, preset, w); } Bitmap mBitmapOut = Bitmap.createBitmap( @@ -88,7 +88,7 @@ public class ImageFilterTinyPlanet extends ImageFilter { return mBitmapOut; } - private Bitmap applyXmp(Bitmap bitmapIn, ImagePreset preset) { + private Bitmap applyXmp(Bitmap bitmapIn, ImagePreset preset, int intermediateWidth) { try { XMPMeta xmp = preset.getImageLoader().getXmpObject(); if (xmp == null) { @@ -106,13 +106,17 @@ public class ImageFilterTinyPlanet extends ImageFilter { int left = getInt(xmp, CROPPED_AREA_LEFT); int top = getInt(xmp, CROPPED_AREA_TOP); + // Make sure the intermediate image has the similar size to the + // input. + float scale = intermediateWidth / (float) fullPanoWidth; Bitmap paddedBitmap = Bitmap.createBitmap( - fullPanoWidth, fullPanoHeight, Bitmap.Config.ARGB_8888); + (int) (fullPanoWidth * scale), (int) (fullPanoHeight * scale), + Bitmap.Config.ARGB_8888); Canvas paddedCanvas = new Canvas(paddedBitmap); int right = left + croppedAreaWidth; int bottom = top + croppedAreaHeight; - Rect destRect = new Rect(left, top, right, bottom); + RectF destRect = new RectF(left * scale, top * scale, right * scale, bottom * scale); paddedCanvas.drawBitmap(bitmapIn, null, destRect, null); bitmapIn = paddedBitmap; } catch (XMPException ex) { |
