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

Commit 00d64dd5 authored by Ruben Brunk's avatar Ruben Brunk
Browse files

Fix geometry xforms & minor bug.

Bug: 7376048

Fixed geometry transform.  Fixed minor bug where the foldername
for saved edited images was incorrect.

Change-Id: Icb3156f02b7db7b50a455aaa31ee70832e3fdca8
parent c5590eb1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1240,7 +1240,7 @@ public class PhotoPage extends ActivityState implements
                if (resultCode == Activity.RESULT_OK) {
                if (resultCode == Activity.RESULT_OK) {
                    Context context = mActivity.getAndroidContext();
                    Context context = mActivity.getAndroidContext();
                    String message = context.getString(R.string.crop_saved,
                    String message = context.getString(R.string.crop_saved,
                            context.getString(R.string.folder_download));
                            context.getString(R.string.folder_edited_online_photos));
                    Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
                    Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
                }
                }
                break;
                break;
+7 −17
Original line number Original line Diff line number Diff line
@@ -63,21 +63,6 @@ public class ImageFilterGeometry extends ImageFilter {
    native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight,
    native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight,
            Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
            Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);


    public Matrix buildMatrix(RectF r) {
        float dx = r.width()/2;
        float dy = r.height()/2;
        if(mGeometry.hasSwitchedWidthHeight()){
            float temp = dx;
            dx = dy;
            dy = temp;
        }
        float w = r.left * 2 + r.width();
        float h = r.top * 2 + r.height();
        Matrix m = mGeometry.buildGeometryMatrix(w, h, 1f, dx, dy, false);

        return m;
    }

    @Override
    @Override
    public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
    public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
        // TODO: implement bilinear or bicubic here... for now, just use
        // TODO: implement bilinear or bicubic here... for now, just use
@@ -94,7 +79,12 @@ public class ImageFilterGeometry extends ImageFilter {
            temp = Bitmap.createBitmap(cropBounds.width(), cropBounds.height(), mConfig);
            temp = Bitmap.createBitmap(cropBounds.width(), cropBounds.height(), mConfig);
        }
        }


        Matrix drawMatrix = buildMatrix(crop);
        RectF rp = mGeometry.getPhotoBounds();
        RectF rc = mGeometry.getPreviewCropBounds();
        Matrix drawMatrix = mGeometry.buildTotalXform(rp.width(), rp.height(), rc.width(),
                rc.height(), rc.left, rc.top,
                mGeometry.getRotation(), mGeometry.getStraightenRotation(),
                bitmap.getWidth() / rp.width(), null);
        Canvas canvas = new Canvas(temp);
        Canvas canvas = new Canvas(temp);
        canvas.drawBitmap(bitmap, drawMatrix, new Paint());
        canvas.drawBitmap(bitmap, drawMatrix, new Paint());
        return temp;
        return temp;
+17 −0
Original line number Original line Diff line number Diff line
@@ -239,4 +239,21 @@ public class GeometryMetadata {
        float h = mPhotoBounds.height();
        float h = mPhotoBounds.height();
        return buildGeometryMatrix(w, h, scaling, dx, dy, false);
        return buildGeometryMatrix(w, h, scaling, dx, dy, false);
    }
    }

    public Matrix buildTotalXform(float pwidth, float pheight, float cwidth, float cheight,
            float cleft, float ctop, float rotation, float straighten, float scale, RectF dst) {
        Matrix m = getFlipMatrix(pwidth, pheight);
        m.postRotate(rotation + straighten, pwidth / 2, pheight / 2);
        Matrix m1 = new Matrix();
        m1.setRotate(rotation, pwidth / 2, pheight / 2);
        // find new top left for crop.
        RectF crop = new RectF(cleft, ctop, cleft + cwidth, ctop + cheight);
        if (!m1.mapRect(crop))
            return null;
        if (dst != null)
            dst.set(crop);
        m.postTranslate(-crop.left, -crop.top);
        m.postScale(scale, scale);
        return m;
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@ import com.android.gallery3d.filtershow.imageshow.GeometryMetadata.FLIP;
public class ImageFlip extends ImageGeometry {
public class ImageFlip extends ImageGeometry {


    private static final Paint gPaint = new Paint();
    private static final Paint gPaint = new Paint();
    private static final float MIN_FLICK_DIST_FOR_FLIP = 0.2f;
    private static final float MIN_FLICK_DIST_FOR_FLIP = 0.1f;
    private static final String LOGTAG = "ImageFlip";
    private static final String LOGTAG = "ImageFlip";
    private FLIP mNextFlip = FLIP.NONE;
    private FLIP mNextFlip = FLIP.NONE;