Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 975dd5f4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Gallery2: use even width and height for makeup"

parents 567c35fc e099032b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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()
+26 −0
Original line number Diff line number Diff line
@@ -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;