颤振如何使用CameraX takePicture(OnImageCapturedListener)获取内存中的缓冲区图像

时间:2019-06-18 01:17:20

标签: android android-intent flutter

我试图让Flutter使用CameraX来使用In-Memory Buffer拍照,而不是保存到磁盘。
在CameraX ImageCapture.Java中,我找到了此代码段

// Wrap the ImageCapture.OnImageSavedListener with an OnImageCapturedListener so it can
// be put into the capture request queue
OnImageCapturedListener imageCaptureCallbackWrapper =
        new OnImageCapturedListener() {
            @Override
            public void onCaptureSuccess(ImageProxy image, int rotationDegrees) {
                Handler completionHandler = (mHandler != null) ? mHandler : mMainHandler;
                CameraXExecutors.ioExecutor()
                        .execute(
                                new ImageSaver(
                                        image,
                                        saveLocation,
                                        rotationDegrees,
                                        metadata.isReversedHorizontal,
                                        metadata.isReversedVertical,
                                        metadata.location,
                                        imageSavedListenerWrapper,
                                        completionHandler));
            }

            @Override
            public void onError(
                    UseCaseError error, String message, @Nullable Throwable cause) {
                imageSavedListener.onError(error, message, cause);
            }
        };

该示例与Camera Preview有关
如何在CameraX Core中将Intent与内存缓冲区图像一起使用?

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));     
    => change to   
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, InMemoryBuffer); 
    startActivityForResult(takePictureIntent, REQUEST_TAKE_IMAGE);

谢谢

0 个答案:

没有答案