0

我从前视图用相机拍了一张照片。现在我想裁剪图像的中心,但是当我将代码 xwidth > xheight 放在我的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()
                     );

                }
4

0 回答 0