diff options
| author | Jay Wang <jaywang@codeaurora.org> | 2016-06-28 13:29:26 -0700 |
|---|---|---|
| committer | Jay Wang <jaywang@codeaurora.org> | 2016-07-13 16:52:49 -0700 |
| commit | e099032b017d09d87327036b14cd7f96da785cd4 (patch) | |
| tree | e73066c02426dd4dcb3e153e962c3a0fd4f392a1 /src/com | |
| parent | b7f0f7f067f5979e7e7e52aa9836ed3dbcca475c (diff) | |
| download | android_packages_apps_Gallery2-e099032b017d09d87327036b14cd7f96da785cd4.tar.gz android_packages_apps_Gallery2-e099032b017d09d87327036b14cd7f96da785cd4.tar.bz2 android_packages_apps_Gallery2-e099032b017d09d87327036b14cd7f96da785cd4.zip | |
Gallery2: use even width and height for makeup
Makeup library requires to have even width and height image.
CRs-Fixed: 999059
Change-Id: I30fb80838c4324be7a62564a01804ffd28ec096a
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 10 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/imageshow/MasterImage.java | 26 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index f0af615c0..6d666d31b 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -1151,6 +1151,16 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL Bitmap originalHires = ImageLoader.loadOrientedConstrainedBitmap(master.getUri(), master.getActivity(), highresPreviewSize, master.getOrientation(), bounds); + + // Force the bitmap to even width and height which is required by beautification algo + Bitmap tempBmp = MasterImage.convertToEvenNumberWidthImage(originalHires); + if(tempBmp != null && originalHires != null) { + if(!originalHires.isRecycled() && originalHires != tempBmp) { + originalHires.recycle(); + } + originalHires = tempBmp; + } + master.setOriginalBounds(bounds); master.setOriginalBitmapHighres(originalHires); Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.doInBackground(): originalHires.WH is (" + originalHires.getWidth() diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java index b2aae85a6..fa82989bb 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java +++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java @@ -272,6 +272,24 @@ public class MasterImage implements RenderingRequestCaller { } }; + public static Bitmap convertToEvenNumberWidthImage(Bitmap bmp) { + Bitmap retBmp = null; + if (bmp != null) { + int w = bmp.getWidth(); + int h = bmp.getHeight(); + boolean bWidthIsEven = (w & 0x01) == 0; + boolean bHeightIsEven = (h & 0x01) == 0; + Log.v(LOGTAG, "ori bitmap w="+w+" h="+h); + if( !bWidthIsEven || !bHeightIsEven){ + w = w - (w & 0x01); + h = h - (h & 0x01); + retBmp = Bitmap.createBitmap(bmp, 0, 0, w, h); + Log.v(LOGTAG, "new bitmap w="+retBmp.getWidth()+" h="+retBmp.getHeight()); + } + } + return retBmp; + } + public boolean loadBitmap(Uri uri, int size) { setUri(uri); mEXIF = ImageLoader.getExif(getActivity(), uri); @@ -280,6 +298,14 @@ public class MasterImage implements RenderingRequestCaller { mOriginalBitmapLarge = ImageLoader.loadOrientedConstrainedBitmap(uri, mActivity, Math.min(MAX_BITMAP_DIM, size), mOrientation, originalBounds); + // Force bitmap width and height to even number for beautification algo. + Bitmap tempBmp = convertToEvenNumberWidthImage(mOriginalBitmapLarge); + if(tempBmp != null && mOriginalBitmapLarge != null) { + if(!mOriginalBitmapLarge.isRecycled() && mOriginalBitmapLarge != tempBmp) { + mOriginalBitmapLarge.recycle(); + } + mOriginalBitmapLarge = tempBmp; + } setOriginalBounds(originalBounds); if (mOriginalBitmapLarge == null) { return false; |
