Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.86k stars 2.16k forks source link

Hope to cut the picture after the rotation #326

Closed dielian-wizard-ly closed 7 years ago

dielian-wizard-ly commented 7 years ago

When the image is rotated by 90 degrees, the crop image still does not rotate before the picture. Hoping to change the picture after the crop rotation

hero0812 commented 7 years ago

As the code in BitmapCropTask.java shows: boolean shouldCrop = shouldCrop(mCroppedImageWidth, mCroppedImageHeight); Log.i(TAG, "Should crop: " + shouldCrop);

    if (shouldCrop) {
        boolean cropped = cropCImg(mImageInputPath, mImageOutputPath,
                cropOffsetX, cropOffsetY, mCroppedImageWidth, mCroppedImageHeight,
                mCurrentAngle, resizeScale, mCompressFormat.ordinal(), mCompressQuality,
                mExifInfo.getExifDegrees(), mExifInfo.getExifTranslation());
        if (cropped && mCompressFormat.equals(Bitmap.CompressFormat.JPEG)) {
            ImageHeaderParser.copyExif(originalExif, mCroppedImageWidth, mCroppedImageHeight, mImageOutputPath);
        }
        return cropped;
    } else {
        FileUtils.copyFile(mImageInputPath, mImageOutputPath);
        return false;
    }

if you rotate the image and the overlay simultaneously,the fun cropCImg() will return false...According to the design of UCrop, overlay and its Rect is stable while image can be rotated. My way to solve the problem is to judge if (shouldCrop||mCurrentAngle!=0) --just crop if image has been roated

severianremi commented 7 years ago

Hello, @dielian-wizard-ly, @hero0812. Fix for this issue was merged into master.