summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-09-13 17:02:21 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-14 12:08:10 -0700
commit53106863f168e5a5404b70781fedc74090c09a1f (patch)
tree95604e4e39c62bef2cba02b794ffd0ad08a5a061 /src
parenteeb2253db1ee359acb0ec0df177290d7d1d15c29 (diff)
downloadandroid_packages_apps_Gallery2-53106863f168e5a5404b70781fedc74090c09a1f.tar.gz
android_packages_apps_Gallery2-53106863f168e5a5404b70781fedc74090c09a1f.tar.bz2
android_packages_apps_Gallery2-53106863f168e5a5404b70781fedc74090c09a1f.zip
SnapdragonGallery: check for valid background before saving
Check to make sure previously selected background is valid before attempting to flatten and save. If background does not exist, save without background. CRs-Fixed: 1062655 Change-Id: I1a3553d6d93d949b6884d3f3301d6f1f53348393
Diffstat (limited to 'src')
-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;
}
}