我从前视图拍摄了相机照片。现在我想裁剪图像的中心,但是当我把代码放到xwidth>在我的PictureCallback
功能内部,相机冻结了。我正在从相机拍摄四张照片,就像在连拍模式下一样。我的目标是从中心裁剪每个图像:
没有冻结相机。
PictureCallback myPictureCallback_JPG = new PictureCallback(){
@Override
public void onPictureTaken(byte[] arg0, Camera arg1) {
// TODO Auto-generated method stub
try {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length,options);
int xxWidth = bitmapPicture.getWidth();
int xHeight = bitmapPicture.getHeight();
if (xxWidth >=xHeight){
bitmapPicture = Bitmap.createBitmap(
bitmapPicture,
xxWidth/2 - xHeight/2,
0,
bitmapPicture.getHeight(),
bitmapPicture.getHeight()
);
}