summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2012-10-24 20:04:48 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-24 20:04:48 -0700
commit2696d692dcf04c36f92455bdd9dc662487689707 (patch)
tree78d603790f2ccf955f86848c0d39427468d65146 /src
parent0817895a0de7f0295ed06fa7ac4cff624479797a (diff)
parent6ebc5501d1e577f243beb306c3493f77b25c4794 (diff)
downloadandroid_packages_apps_Snap-2696d692dcf04c36f92455bdd9dc662487689707.tar.gz
android_packages_apps_Snap-2696d692dcf04c36f92455bdd9dc662487689707.tar.bz2
android_packages_apps_Snap-2696d692dcf04c36f92455bdd9dc662487689707.zip
Merge "Fixes TinyPlanet crashed due to too excessive memory usage." into gb-ub-photos-arches
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java16
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) {