diff options
author | John Hoford <hoford@google.com> | 2012-11-08 12:04:26 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-11-08 12:04:26 -0800 |
commit | 4c1614b7845252209742411acd09723e2245b8f8 (patch) | |
tree | de6b4b8f0dc396fb02a548f3b5b1fa89ea6a74b2 | |
parent | d7545049bfe7142389eae84394d6b76ed9b68fb2 (diff) | |
parent | 8253c35a5d9564afbc667f7a9f42fdc0a734bcf8 (diff) | |
download | android_packages_apps_Gallery2-4c1614b7845252209742411acd09723e2245b8f8.tar.gz android_packages_apps_Gallery2-4c1614b7845252209742411acd09723e2245b8f8.tar.bz2 android_packages_apps_Gallery2-4c1614b7845252209742411acd09723e2245b8f8.zip |
am 8253c35a: reduce size of tiny planet if malloc fails - DO NOT MERGE
* commit '8253c35a5d9564afbc667f7a9f42fdc0a734bcf8':
reduce size of tiny planet if malloc fails - DO NOT MERGE
-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; |