我在surfaceView的顶部有一个ImageView,现在我单击与该SurfaceView大小相同的图像,现在我只需要ImageView下的部分图像。为此,我正在使用代码:
private void setupImageDisplay() {
Bitmap bitmap = BitmapFactory.decodeByteArray(mCameraData, 0, mCameraData.length);
int[] location = new int[2];
mCameraPreview.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
Bitmap resizedbitmap1=Bitmap.createBitmap(bitmap, x,y,mCameraPreview.getWidth(), mCameraPreview.getHeight());
mCameraImage.setImageBitmap(resizedbitmap1);
mCamera.stopPreview();
mCameraPreview.setVisibility(View.INVISIBLE);
s1.setVisibility(View.INVISIBLE);
v1.setVisibility(View.INVISIBLE);
mCameraImage.setVisibility(View.VISIBLE);
mCaptureImageButton.setText(R.string.recapture_image);
mCaptureImageButton.setOnClickListener(mRecaptureImageButtonClickListener);
}
但是它裁剪了位图的左上部分。所以我在这里做错了吗? 请帮忙!