summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-09-15 07:16:27 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-15 07:16:27 -0700
commitc6c9d2737eea0708b0798477a3da732d2c2e7ba0 (patch)
treefaf73fda0d40eac9439a99e910fb6de9210bb6b6
parentb47ac6f1f68eaee60374b23ea5a69e504477ba9e (diff)
parent53106863f168e5a5404b70781fedc74090c09a1f (diff)
downloadandroid_packages_apps_Gallery2-c6c9d2737eea0708b0798477a3da732d2c2e7ba0.tar.gz
android_packages_apps_Gallery2-c6c9d2737eea0708b0798477a3da732d2c2e7ba0.tar.bz2
android_packages_apps_Gallery2-c6c9d2737eea0708b0798477a3da732d2c2e7ba0.zip
Merge "SnapdragonGallery: check for valid background before saving"
-rw-r--r--src/com/android/gallery3d/filtershow/tools/SaveImage.java53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
index 87492a335..073aca4cd 100644
--- a/src/com/android/gallery3d/filtershow/tools/SaveImage.java
+++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
@@ -368,6 +368,11 @@ public class SaveImage {
if(hasFusion) {
previewBmp = flattenFusion(Uri.parse(fusionRep.getUnderlay()), mPreviewImage,
Math.max(mPreviewImage.getWidth(), mPreviewImage.getHeight()), 0);
+ // If we fail to flatten, save original image
+ if(previewBmp == null) {
+ previewBmp = mPreviewImage;
+ hasFusion = false;
+ }
} else {
previewBmp = mPreviewImage;
}
@@ -447,9 +452,10 @@ public class SaveImage {
if(hasFusion) {
Bitmap underlay = flattenFusion(
Uri.parse(fusionRep.getUnderlay()), bitmap, 0, sampleSize);
-
- bitmap.recycle();
- bitmap = underlay;
+ if(underlay != null) {
+ bitmap.recycle();
+ bitmap = underlay;
+ }
}
updateProgress();
@@ -820,26 +826,27 @@ public class SaveImage {
underlay = ImageLoader.loadBitmapWithBackouts(mContext, underlayUri, sampleSize);
}
- RectF destRect = new RectF();
- Rect imageBounds = MasterImage.getImage().getImageBounds();
- Rect underlayBounds = MasterImage.getImage().getFusionBounds();
- float underlayScaleFactor = (float)underlay.getWidth()
- / (float)underlayBounds.width();
-
- destRect.left = (imageBounds.left - underlayBounds.left) * underlayScaleFactor;
- destRect.right = (imageBounds.right - underlayBounds.left) * underlayScaleFactor;
- destRect.top = (imageBounds.top - underlayBounds.top) * underlayScaleFactor;
- destRect.bottom = (imageBounds.bottom - underlayBounds.top) * underlayScaleFactor;
-
- Canvas canvas = new Canvas(underlay);
- Paint paint = new Paint();
- paint.reset();
- paint.setAntiAlias(true);
- paint.setFilterBitmap(true);
- paint.setDither(true);
-
- canvas.drawBitmap(bitmap, null, destRect, paint);
-
+ if(underlay != null) {
+ RectF destRect = new RectF();
+ Rect imageBounds = MasterImage.getImage().getImageBounds();
+ Rect underlayBounds = MasterImage.getImage().getFusionBounds();
+ float underlayScaleFactor = (float)underlay.getWidth()
+ / (float)underlayBounds.width();
+
+ destRect.left = (imageBounds.left - underlayBounds.left) * underlayScaleFactor;
+ destRect.right = (imageBounds.right - underlayBounds.left) * underlayScaleFactor;
+ destRect.top = (imageBounds.top - underlayBounds.top) * underlayScaleFactor;
+ destRect.bottom = (imageBounds.bottom - underlayBounds.top) * underlayScaleFactor;
+
+ Canvas canvas = new Canvas(underlay);
+ Paint paint = new Paint();
+ paint.reset();
+ paint.setAntiAlias(true);
+ paint.setFilterBitmap(true);
+ paint.setDither(true);
+
+ canvas.drawBitmap(bitmap, null, destRect, paint);
+ }
return underlay;
}
}