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

Commit a1d2b77d authored by Nicolas Roard's avatar Nicolas Roard Committed by Android Git Automerger
Browse files

am a66584f1: am 8c592dc8: am 65025459: Merge "Added dashed diagonal for crop."...

am a66584f1: am 8c592dc8: am 65025459: Merge "Added dashed diagonal for crop." into gb-ub-photos-arches

* commit 'a66584f1':
  Added dashed diagonal for crop.
parents cf4d5b4a a66584f1
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -203,6 +203,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
        mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
        mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
        mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);
        mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);


        mImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
        ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
        ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
        mImageViews.add(mImageShow);
        mImageViews.add(mImageShow);
        mImageViews.add(mImageCurves);
        mImageViews.add(mImageCurves);
+21 −7
Original line number Original line Diff line number Diff line
@@ -157,38 +157,52 @@ public class PanelController implements OnClickListener {
            ImageCrop imageCrop = (ImageCrop) mCurrentImage;
            ImageCrop imageCrop = (ImageCrop) mCurrentImage;
            switch (itemId) {
            switch (itemId) {
                case R.id.crop_menu_1to1: {
                case R.id.crop_menu_1to1: {
                    button.setText(mContext.getString(R.string.aspect1to1_effect));
                    String t = mContext.getString(R.string.aspect1to1_effect);
                    button.setText(t);
                    imageCrop.apply(1, 1);
                    imageCrop.apply(1, 1);
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_4to3: {
                case R.id.crop_menu_4to3: {
                    button.setText(mContext.getString(R.string.aspect4to3_effect));
                    String t = mContext.getString(R.string.aspect4to3_effect);
                    button.setText(t);
                    imageCrop.apply(4, 3);
                    imageCrop.apply(4, 3);
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_3to4: {
                case R.id.crop_menu_3to4: {
                    button.setText(mContext.getString(R.string.aspect3to4_effect));
                    String t = mContext.getString(R.string.aspect3to4_effect);
                    button.setText(t);
                    imageCrop.apply(3, 4);
                    imageCrop.apply(3, 4);
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_5to7: {
                case R.id.crop_menu_5to7: {
                    button.setText(mContext.getString(R.string.aspect5to7_effect));
                    String t = mContext.getString(R.string.aspect5to7_effect);
                    button.setText(t);
                    imageCrop.apply(5, 7);
                    imageCrop.apply(5, 7);
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_7to5: {
                case R.id.crop_menu_7to5: {
                    button.setText(mContext.getString(R.string.aspect7to5_effect));
                    String t = mContext.getString(R.string.aspect7to5_effect);
                    button.setText(t);
                    imageCrop.apply(7, 5);
                    imageCrop.apply(7, 5);
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_none: {
                case R.id.crop_menu_none: {
                    button.setText(mContext.getString(R.string.aspectNone_effect));
                    String t = mContext.getString(R.string.aspectNone_effect);
                    button.setText(t);
                    imageCrop.applyClear();
                    imageCrop.applyClear();
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
                case R.id.crop_menu_original: {
                case R.id.crop_menu_original: {
                    button.setText(mContext.getString(R.string.aspectOriginal_effect));
                    String t = mContext.getString(R.string.aspectOriginal_effect);
                    button.setText(t);
                    imageCrop.applyOriginal();
                    imageCrop.applyOriginal();
                    imageCrop.setAspectString(t);
                    break;
                    break;
                }
                }
            }
            }
+40 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,17 @@ public class ImageCrop extends ImageGeometry {


    private static final String LOGTAG = "ImageCrop";
    private static final String LOGTAG = "ImageCrop";


    private String mAspect = "";
    private int mAspectTextSize = 24;

    public void setAspectTextSize(int textSize){
        mAspectTextSize = textSize;
    }

    public void setAspectString(String a){
        mAspect = a;
    }

    private static final Paint gPaint = new Paint();
    private static final Paint gPaint = new Paint();


    public ImageCrop(Context context) {
    public ImageCrop(Context context) {
@@ -642,6 +653,35 @@ public class ImageCrop extends ImageGeometry {
        gPaint.setStyle(Paint.Style.STROKE);
        gPaint.setStyle(Paint.Style.STROKE);
        drawRuleOfThird(canvas, crop, gPaint);
        drawRuleOfThird(canvas, crop, gPaint);


        if (mFixAspectRatio){
            float w = crop.width();
            float h = crop.height();
            float diag = (float) Math.sqrt(w*w + h*h);

            float dash_len = 20;
            int num_intervals = (int) (diag / dash_len);
            float [] tl = { crop.left, crop.top };
            float centX = tl[0] + w/2;
            float centY = tl[1] + h/2 + 5;
            float [] br = { crop.right, crop.bottom };
            float [] vec = GeometryMath.getUnitVectorFromPoints(tl, br);

            float [] counter = tl;
            for (int x = 0; x < num_intervals; x++ ){
                float tempX = counter[0] + vec[0] * dash_len;
                float tempY = counter[1] + vec[1] * dash_len;
                if ((x % 2) == 0 && Math.abs(x - num_intervals / 2) > 2){
                    canvas.drawLine(counter[0], counter[1], tempX, tempY, gPaint);
                }
                counter[0] = tempX;
                counter[1] = tempY;
            }

            gPaint.setTextAlign(Paint.Align.CENTER);
            gPaint.setTextSize(mAspectTextSize);
            canvas.drawText(mAspect, centX, centY, gPaint);
        }

        gPaint.setColor(mBorderColor);
        gPaint.setColor(mBorderColor);
        gPaint.setStrokeWidth(3);
        gPaint.setStrokeWidth(3);
        gPaint.setStyle(Paint.Style.STROKE);
        gPaint.setStyle(Paint.Style.STROKE);