YImagePicker icon indicating copy to clipboard operation
YImagePicker copied to clipboard

裁剪时,图片可以完全脱出裁选框外。

Open sj8521123 opened this issue 5 years ago • 11 comments

希望能像微信裁剪样,图片始终在框体里边。

sj8521123 avatar Apr 20 '20 06:04 sj8521123

@sj8521123 支持的! //设置剪裁模式,留白或充满 CropConfig.STYLE_GAP 或 CropConfig.STYLE_FILL .cropStyle(CropConfig.STYLE_FILL)

yangpeixing avatar Apr 20 '20 06:04 yangpeixing

嗯嗯,试了一下,STYLE_FILL模式是可以的,是我没搞清楚这两者的意思,谢谢。

sj8521123 avatar Apr 20 '20 06:04 sj8521123

@sj8521123 感谢您的支持与使用,觉得不错还请留个star支持一下,谢谢🌹

yangpeixing avatar Apr 20 '20 06:04 yangpeixing

刚测试了下,还是在CropConfig.STYLE_FILL模式下,如果调用了图片旋转的方法,会导致不能自动fill充满,而是需要手动滑动下,才能fill充满。

sj8521123 avatar Apr 20 '20 09:04 sj8521123

@sj8521123 不好意思,目前版本暂不支持旋转,后期考虑优化

yangpeixing avatar Apr 20 '20 09:04 yangpeixing

我看了CropImageView源码中有 rotate(),能让位图旋转啊, 但是旋转后,不能自动fill充满。 public void rotate(float degrees) { mDegrees += degrees; int centerX = (int) (mCropRect.left + mCropRect.width() / 2); int centerY = (int) (mCropRect.top + mCropRect.height() / 2);

    mAnimMatrix.postRotate(degrees, centerX, centerY);
    executeTranslate();
}

sj8521123 avatar Apr 20 '20 09:04 sj8521123

解决了, 我在 rotate方法中加了
onUp(); isShowLine = false; invalidate();

sj8521123 avatar Apr 20 '20 09:04 sj8521123

@sj8521123 👍你这只能在调用rotate方法生效,如果想染用户自行旋转图片的话,还需要把isRotateEnable置为true并在旋转手势中处理缩放逻辑

yangpeixing avatar Apr 20 '20 10:04 yangpeixing

@sj8521123 虽然解决了旋转充满,但是剪裁后的图片不对的,如果你调用的是CropConfig.STYLE_FILL的话,CropConfig.STYLE_GAP剪裁的是view没有影响

yangpeixing avatar Apr 20 '20 10:04 yangpeixing

是的,旋转充满没有问题了,但是裁剪有问题,没有成功剪切,显示的还是原图样式,我设置的是CropConfig.STYLE_FILL模式,怎么解决呢?哈哈~

sj8521123 avatar Apr 20 '20 10:04 sj8521123

@sj8521123 涉及到旋转肯定要复杂一点了,这就是我目前还不支持旋转的原因😄,很抱歉啊,这个可能后期我专门花时间研究了。目前的话,你可以使用ucrop框架,如果感兴趣你也可以在cropimageview的基础上修改实现

yangpeixing avatar Apr 20 '20 10:04 yangpeixing