diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2015-12-24 04:29:32 -0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-12-24 04:29:32 -0800 |
| commit | a4a483cf6db4c6702e95bd53e5167d459a8e8022 (patch) | |
| tree | e6eb4b74784b4de914afeea08a4ce54f472d3363 | |
| parent | 62fac4f9fefc7d11091e3f1e125fa2587c38330a (diff) | |
| parent | 98cf80a9900bc5d1ec63e69b3d2a6c1f6792f236 (diff) | |
| download | android_packages_apps_Gallery2-a4a483cf6db4c6702e95bd53e5167d459a8e8022.tar.gz android_packages_apps_Gallery2-a4a483cf6db4c6702e95bd53e5167d459a8e8022.tar.bz2 android_packages_apps_Gallery2-a4a483cf6db4c6702e95bd53e5167d459a8e8022.zip | |
Merge "Gallery2: fix thumbnail issue when using dual cam filter"
| -rw-r--r-- | src/com/android/gallery3d/filtershow/tools/SaveImage.java | 46 |
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); } |
