diff options
author | John Hoford <hoford@google.com> | 2012-11-08 10:41:24 -0800 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2012-11-08 10:41:24 -0800 |
commit | 3c38fb244c0ec4a538c5600af16a289bd652bbe4 (patch) | |
tree | 398b4930413d4d2f4a83fc291341089730201673 /src/com | |
parent | 6f02f74d88efc644d244e9611b56097bf2dcbaec (diff) | |
download | android_packages_apps_Snap-3c38fb244c0ec4a538c5600af16a289bd652bbe4.tar.gz android_packages_apps_Snap-3c38fb244c0ec4a538c5600af16a289bd652bbe4.tar.bz2 android_packages_apps_Snap-3c38fb244c0ec4a538c5600af16a289bd652bbe4.zip |
reduce size of tiny planet if malloc fails
bug:7477815
Change-Id: I03fec9246e368fb7f929769dc5e5e6266761dc34
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java index 423e55828..effd89ebe 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java @@ -22,6 +22,7 @@ import android.graphics.RectF; import com.adobe.xmp.XMPException; import com.adobe.xmp.XMPMeta; +import com.android.gallery3d.app.Log; import com.android.gallery3d.filtershow.presets.ImagePreset; /** @@ -90,8 +91,17 @@ public class ImageFilterTinyPlanet extends ImageFilter { } } - Bitmap mBitmapOut = Bitmap.createBitmap( - outputSize, outputSize, Bitmap.Config.ARGB_8888); + Bitmap mBitmapOut = null; + while (mBitmapOut == null) { + try { + mBitmapOut = Bitmap.createBitmap( + outputSize, outputSize, Bitmap.Config.ARGB_8888); + } catch (java.lang.OutOfMemoryError e) { + System.gc(); + outputSize /= 2; + Log.v(TAG, "No memory to create Full Tiny Planet create half"); + } + } nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut, outputSize, mParameter / 100f, mAngle); return mBitmapOut; @@ -112,10 +122,19 @@ public class ImageFilterTinyPlanet extends ImageFilter { // Make sure the intermediate image has the similar size to the // input. + Bitmap paddedBitmap = null; float scale = intermediateWidth / (float) fullPanoWidth; - Bitmap paddedBitmap = Bitmap.createBitmap( + while (paddedBitmap == null) { + try { + paddedBitmap = Bitmap.createBitmap( (int) (fullPanoWidth * scale), (int) (fullPanoHeight * scale), Bitmap.Config.ARGB_8888); + } catch (java.lang.OutOfMemoryError e) { + System.gc(); + scale /= 2; + Log.v(TAG, "No memory to create Full Tiny Planet create half"); + } + } Canvas paddedCanvas = new Canvas(paddedBitmap); int right = left + croppedAreaWidth; |