裁剪区域显示不正确

问题描述

您好,我使用 MianaCropView 为我的用户提供了在上传图片之前裁剪图片的可能性。当关于结果裁剪问题来自上传前向用户显示的预览时,一切正常。 我为用户提供了从 (1:1 到 16:9) 的不同纵横比裁剪图像的可能性。

用户选择缩放阴影时,图像的女巫部分将保留,女巫部分将被裁剪(Here an example of a image with 16:9 Scale)

问题是当我使用 1.91:1 时,预览与结果不匹配,并且可能会向用户提供最终图像的错误表示。 Here's the preview who's show to the userhere the real result 。我需要预览以匹配真实结果。

我该如何解决

这是我更新cropeArea的代码

private void updateCropArea() {
    int width = getMeasuredWidth();
    int height = getMeasuredHeight();
    if (width == 0 || height == 0) {
        return;
    }
    //compute cropArea
    float left,rigth,top,bottom;
    float finalWidth = 0;
    float finalHeight = 0;
    switch (mCropType) {
        case SQUARE:
            finalWidth = finalHeight = width < height ? width : height;
            break;
    The problem is here :    case SCALE_1_91_1:
            finalHeight = height;

            finalWidth = finalHeight *  1.91f/1;
            break;
        case SCALE_2_3:
            finalHeight = height;
            finalWidth = finalHeight * 2 / 3;
            break;
        case SCALE_3_4:
            finalHeight = height;
            finalWidth = finalHeight * 3 / 4;
            break;
        case SCALE_3_2:
            finalWidth = width;
            finalHeight = finalWidth * 2 / 3;
            break;
        case SCALE_4_3:
            finalWidth = width;
            finalHeight = finalWidth * 3 / 4;
            break;
        case SCALE_4_5:
            finalHeight = height;
            finalWidth = finalHeight * 4 / 5;
            break;
        case SCALE_16_9:
            finalWidth = width;
            finalHeight = finalWidth * 9 / 16;
            break;

    }
    left = (width - finalWidth) * 0.5f;
    top = (height - finalHeight) * 0.5f;
    rigth = left + finalWidth;
    bottom = top + finalHeight;

    RectF cropArea = new RectF(left,bottom);
    mdisplayHelper.setCropArea(cropArea);
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)