0

此处未显示图像。两天前它还在工作,但我做了一些更改,但出了点问题。这是我放在 jpeg Callback 的 onPictureTaken (byte[] data , Camera camera) 方法中的代码。logcat 显示 onPicture Taken Text 但不显示前两个文本“回调收到空数据”和“未创建位图”

预览是高度和宽度都匹配父级的线性布局。

输出显示空白屏幕。

    capture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            captureStatus = 1 ;
            Camera.PictureCallback rawCallback = new Camera.PictureCallback() {

                @Override
                public void onPictureTaken(byte[] data, Camera camera) {
                    // TODO Auto-generated method stub

                    if (data == null) {
                        System.out.println("callback decieved null data");
                    }

                    mCamera = mPreview.stopCamera();
                    picture = BitmapFactory.decodeByteArray(data, 0, data.length, null);
                    Matrix mat = new Matrix();
                    mat.postRotate(90);
                    Bitmap newBitmap = Bitmap.createBitmap(picture, 0, 0, picture.getWidth(), picture.getHeight(), mat, true) ;
                    pic = new ImageView(c);
                    pic.setImageBitmap(newBitmap);
                    preview.removeAllViews();
                    preview.addView(pic);
                    preview.requestLayout();
                    System.out.println("On picture taken");

                }
            };

        try {
            mPreview.yCamera.takePicture(null, null,rawCallback);
        } catch (Exception e) {
        e.printStackTrace();
        }
        }
    });
4

0 回答 0