Convert android.media.Image (YUV_420_888) to Bitmap

后端 未结 3 1467
生来不讨喜
生来不讨喜 2020-12-09 10:57

I\'m trying to implement camera preview image data processing using camera2 api as proposed here: Camera preview image data processing with Android L and Camera2 API.

<
3条回答
  •  粉色の甜心
    2020-12-09 11:46

    I write some code about this, and it's the YUV datas preview and chang it to JPEG datas ,and I can use it to save as bitmap ,byte[] ,or others.(You can see the class "Allocation" ).

    And SDK document says:
    "For efficient YUV processing with android.renderscript: Create a RenderScript Allocation with a supported YUV type, the IO_INPUT flag, and one of the sizes returned by getOutputSizes(Allocation.class), Then obtain the Surface with getSurface()."

    here is the code, hope it will help you:https://github.com/pinguo-yuyidong/Camera2/blob/master/camera2/src/main/rs/yuv2rgb.rs

提交回复
热议问题