Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

裁剪之后,保存的图片显示范围超过裁剪范围 #126

Open
zpswz opened this issue Mar 9, 2022 · 5 comments
Open

裁剪之后,保存的图片显示范围超过裁剪范围 #126

zpswz opened this issue Mar 9, 2022 · 5 comments

Comments

@zpswz
Copy link

zpswz commented Mar 9, 2022

caijian1
caijian2

是有什么地方设置不对吗

@maoxiaozhu
Copy link

这个问题你解决了吗?

@maoxiaozhu
Copy link

caijian1 caijian2

是有什么地方设置不对吗

解决了吗

@zpswz
Copy link
Author

zpswz commented Dec 30, 2022

菜见1 菜见2
有什么地方设置不对吗

解决了吗

没有作者都没有发解决方案

@luoye000
Copy link

我在部分机型上遇到了这个问题

修复方案

@Override
    public Bitmap getBitmap() {
        Bitmap bmp = null;
        Drawable drawable = getDrawable();
        if (drawable instanceof BitmapDrawable) {
            bmp = ((BitmapDrawable) drawable).getBitmap();
        }
        //修复裁剪区域不一致问题
        if (bmp != null) {
            int width = drawable.getIntrinsicWidth();
            int height = drawable.getIntrinsicHeight();
            int bitWidth = bmp.getWidth();
            int bitHeight = bmp.getHeight();
            if (width != bitWidth || height != bitHeight) {
                Matrix matrix = new Matrix();
                matrix.setScale(1.0f * width / bitWidth, 1.0f * height / bitHeight);
                return Bitmap.createBitmap(bmp, 0, 0, bitWidth, bitHeight, matrix, true);
            }
        }
        return bmp;
    }

这两个方法获取出的 大小不一致造成的

private Point[] getFullImgCropPoints() {
        Point[] points = new Point[4];
        Drawable drawable = getDrawable();
        if (drawable != null) {
            int width = drawable.getIntrinsicWidth();
            int height = drawable.getIntrinsicHeight();
            points[0] = new Point(0, 0);
            points[1] = new Point(width, 0);
            points[2] = new Point(width, height);
            points[3] = new Point(0, height);
        }
        return points;
    }

   

public Bitmap getBitmap() {

        Bitmap bmp = null;
        Drawable drawable = getDrawable();
        if (drawable instanceof BitmapDrawable) {
            bmp = ((BitmapDrawable) drawable).getBitmap();
        }
        return bmp;
    }

@codeguyFred
Copy link

适配方案的原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants