Android 按代码而不是用户从相机裁剪图片(创建位图)

Android 按代码而不是用户从相机裁剪图片(创建位图),android,android-layout,bitmap,Android,Android Layout,Bitmap,我正试图从相机上截取一张照片,但它被放大了。宽度和高度都可以,但放大了很多 这是我的代码: 这是我用来缩放位图的代码,wantedWidth和wantedHeight将是视图的宽度和高度 public static Bitmap scaleBitmap(Bitmap bitmap, int wantedWidth, int wantedHeight) { Bitmap output = Bitmap.createBitmap(wantedWidth, wantedHeight, Conf

我正试图从相机上截取一张照片,但它被放大了。宽度和高度都可以,但放大了很多

这是我的代码:


这是我用来缩放位图的代码,wantedWidth和wantedHeight将是视图的宽度和高度

public static Bitmap scaleBitmap(Bitmap bitmap, int wantedWidth, int wantedHeight) {
    Bitmap output = Bitmap.createBitmap(wantedWidth, wantedHeight, Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    Matrix m = new Matrix();
    m.setScale((float) wantedWidth / bitmap.getWidth(), (float) wantedHeight / bitmap.getHeight());
    canvas.drawBitmap(bitmap, m, new Paint());
    return output;
}

将代码和错误复制/粘贴为文本,而不是上传其屏幕截图。