summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-07-25 20:25:16 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-07-25 20:25:15 -0700
commit975dd5f4eb6184fbca64c91a891536aa9610cf9b (patch)
tree55a37ab3056e2254679373e0b68983ce6ef493a3 /src/com
parent567c35fcfb59d1696b534fdc81f3a765911f3562 (diff)
parente099032b017d09d87327036b14cd7f96da785cd4 (diff)
downloadandroid_packages_apps_Gallery2-975dd5f4eb6184fbca64c91a891536aa9610cf9b.tar.gz
android_packages_apps_Gallery2-975dd5f4eb6184fbca64c91a891536aa9610cf9b.tar.bz2
android_packages_apps_Gallery2-975dd5f4eb6184fbca64c91a891536aa9610cf9b.zip
Merge "Gallery2: use even width and height for makeup"
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java10
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java26
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 0f0604ab4..cfce7c54a 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -1156,6 +1156,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;