使用Image.Format FLEX_RGBA_8888将android.media.Image转换为位图

时间:2019-11-17 16:25:24

标签: android image bitmap converters

我正在使用一些基于Android的摄像头设备。我可以从中获取android.media.Image(FLEX_RGBA_8888)对象,但是对于图像处理,我需要将其转换为Bitmap。

ImageReader imageReader = ImageReader.newInstance(w, h, PixelFormat.RGBA_8888, 3);
imageReader.setOnImageAvailableListener(reader -> {
                try (Image img = reader.acquireLatestImage()) {
                    Log.i(TAG, "received image");
                    // convert to Bitmap and process it 
                }
            }, null);

我找到了一些用于其他ImageFormat的转换示例,但是我特别需要这一示例。

0 个答案:

没有答案
相关问题