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 | 6ebc5501d1e577f243beb306c3493f77b25c4794 (patch) | |
tree | 41c270049213d46af1ea986598cc9ed4bd01ffca /src | |
parent | e7647cf87c7303c4f9b7a2dd57d6c70563a63655 (diff) | |
download | android_packages_apps_Snap-6ebc5501d1e577f243beb306c3493f77b25c4794.tar.gz android_packages_apps_Snap-6ebc5501d1e577f243beb306c3493f77b25c4794.tar.bz2 android_packages_apps_Snap-6ebc5501d1e577f243beb306c3493f77b25c4794.zip |
Fixes TinyPlanet crashed due to too excessive memory usage.
Bug: 7409664
Change-Id: If82882ce7186500f5a3af769d490275233a6191c
Diffstat (limited to 'src')
-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) { |