裁剪区域显示不正确

4ioopgfo  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(267)

嗨,我使用的是mianacropview,允许我的用户在上传之前裁剪他们的图片。一切都很好的工作,当它的结果裁剪的问题来自预览显示给用户之前上传。我给用户的可能性,裁剪他们的形象在不同的纵横比(1:1至16:9)。
当用户选择比例时,阴影显示图像的哪个部分将保留,哪个部分将被裁剪(这里是比例为16:9的图像示例)
问题是当我使用1.91:1的预览不匹配的结果,可以给最终的图像错误的代表给用户。这里是预览谁的显示给用户和这里的真实结果。我需要预演与真实结果相符。
我该怎么修?
这是我的代码来提高大梨树

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, top, rigth, bottom);
    mDisplayHelper.setCropArea(cropArea);
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题