summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorCullum Baldwin <cullumb@codeaurora.org>2015-10-31 01:27:35 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-12-22 17:39:15 -0800
commit98cf80a9900bc5d1ec63e69b3d2a6c1f6792f236 (patch)
tree2f49279f8f9d25daa0d9a2fcdc85ec9f41888d7b /src/com/android
parentbef493ddf521f05c6d9a954e328c746dbc363cc1 (diff)
downloadandroid_packages_apps_Gallery2-98cf80a9900bc5d1ec63e69b3d2a6c1f6792f236.tar.gz
android_packages_apps_Gallery2-98cf80a9900bc5d1ec63e69b3d2a6c1f6792f236.tar.bz2
android_packages_apps_Gallery2-98cf80a9900bc5d1ec63e69b3d2a6c1f6792f236.zip
Gallery2: fix thumbnail issue when using dual cam filter
When using some dual cam filter, the thumbnail shown to user did not match final saved image because filter was not being correctly applied to preview thumbnail. Correctly apply filter to preview thumbnail so that it matches final saved image. Change-Id: Ib8b750c7681aac38bef76dd90cb831ca6ac5ab5b
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/filtershow/tools/SaveImage.java46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
index f04466f1b..cbe0f91a3 100644
--- a/src/com/android/gallery3d/filtershow/tools/SaveImage.java
+++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
@@ -359,12 +359,47 @@ public class SaveImage {
Uri savedUri = mSelectedImageUri;
if (mPreviewImage != null) {
+ Bitmap previewBmp;
+ // Check for Fusion
+ FilterDualCamFusionRepresentation fusionRep =
+ (FilterDualCamFusionRepresentation) preset.getFilterWithSerializationName(
+ FilterDualCamFusionRepresentation.SERIALIZATION_NAME);
+ boolean hasFusion = (fusionRep != null && fusionRep.hasUnderlay());
+ if(hasFusion) {
+ // fusion. decode underlay image and get dest rect
+ Uri underLayUri = Uri.parse(fusionRep.getUnderlay());
+ Bitmap underlay = ImageLoader.loadConstrainedBitmap(underLayUri, mContext,
+ Math.max(mPreviewImage.getWidth(), mPreviewImage.getHeight()), null, false);
+ 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(mPreviewImage, null, destRect, paint);
+ previewBmp = underlay;
+ } else {
+ previewBmp = mPreviewImage;
+ }
+
if (flatten) {
Object xmp = getPanoramaXMPData(newSourceUri, preset);
ExifInterface exif = getExifData(newSourceUri);
long time = System.currentTimeMillis();
updateExifData(exif, time);
- if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) {
+ if (putExifData(mDestinationFile, exif, previewBmp, quality)) {
putPanoramaXMPData(mDestinationFile, xmp);
ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time);
Object result = mContext.getContentResolver().insert(
@@ -377,7 +412,7 @@ public class SaveImage {
long time = System.currentTimeMillis();
updateExifData(exif, time);
// If we succeed in writing the bitmap as a jpeg, return a uri.
- if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) {
+ if (putExifData(mDestinationFile, exif, previewBmp, quality)) {
putPanoramaXMPData(mDestinationFile, xmp);
// mDestinationFile will save the newSourceUri info in the XMP.
if (!flatten) {
@@ -390,6 +425,13 @@ public class SaveImage {
mDestinationFile, time, false);
}
}
+
+ if(hasFusion) {
+ // recycle bitmap
+ previewBmp.recycle();
+ previewBmp = null;
+ }
+
if (mCallback != null) {
mCallback.onPreviewSaved(savedUri);
}