裁剪区域矩形显示以前裁剪的区域,如 whats app

Cropped area rectangle show where previously cropped area like whats app

我正在开发 Photoshop 类型的应用程序,其中裁剪工具用于裁剪图像并且我使用默认的裁剪意图,当我裁剪图像时我得到的包中我得到了 Rect(0,0-2,122) 左,top,right,bottom 但我的意思是,当我第一次裁剪时,我再次裁剪裁剪器显示其先前裁剪的区域不是默认区域并且在裁剪意图中。

CropIntent.putExtra("outputX", imageWidth);
CropIntent.putExtra("outputY", imageHeight);
CropIntent.putExtra("aspectX", 100);
CropIntent.putExtra("aspectY", -100);
CropIntent.putExtra("spotlightX", 10);
CropIntent.putExtra("spotlightY", -10);

我像这样传递 l、t、r、b,我知道这是错误的,但我尝试了纵横比 x 和纵横比 y 是比率,但聚光灯是什么,我不知道。我可以将裁剪器放在同一图像上之前裁剪过的区域吗?

您可以使用来自 here

的这个库

并使用下面的方法二恢复图像的比例,并在要裁剪图像的地方调用它,记住切换 Activity 时不要完成它。

 public void updateCurrentCropViewOptions() {
    CropImageViewOptions options = new CropImageViewOptions();
    options.scaleType = mCropImageView.getScaleType();
    options.cropShape = mCropImageView.getCropShape();
    options.guidelines = mCropImageView.getGuidelines();
    options.aspectRatio = mCropImageView.getAspectRatio();
    options.fixAspectRatio = mCropImageView.isFixAspectRatio();
    options.showCropOverlay = mCropImageView.isShowCropOverlay();
    options.showProgressBar = mCropImageView.isShowProgressBar();
    options.autoZoomEnabled = mCropImageView.isAutoZoomEnabled();
    options.maxZoomLevel = mCropImageView.getMaxZoom();
    options.flipHorizontally = mCropImageView.isFlippedHorizontally();
    options.flipVertically = mCropImageView.isFlippedVertically();
}