我将ImageSurfaceView用于自定义相机,并在其上添加了一个矩形,我需要裁剪图像的矩形部分。所以我用下面的代码来裁剪
val bh = bitmap.height
val bw = bitmap.width
val width = vF_atv_camera_preview!!.width;
val height = vF_atv_camera_preview!!.height;
val location = IntArray(2)
vL_atv_box!!.getLocationOnScreen(location);
val l = location[0] * bw / width
val t = location[1] * bh / height
val w = vL_atv_box!!.getWidth() * bw / width;
val h = vL_atv_box!!.getHeight() * bh / height;
val resizedBitmap = Bitmap.createBitmap(bitmap, l, t, w, h);
在所有屏幕尺寸上都无法正确裁剪,请帮助我。