Convert android.media.Image (YUV_420_888) to Bitmap

后端 未结 3 1471
生来不讨喜
生来不讨喜 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:51

    For a simpler solution see my implementation here:

    Conversion YUV 420_888 to Bitmap (full code)

    The function takes the media.image as input, and creates three RenderScript allocations based on the y-, u- and v-planes. It follows the YUV_420_888 logic as shown in this Wikipedia illustration.

    However, here we have three separate image planes for the Y, U and V-channels, thus I take these as three byte[], i.e. U8 allocations. The y-allocation has size width * height bytes, while the u- and v-allocatons have size width * height/4 bytes each, reflecting the fact that each u-byte covers 4 pixels (ditto each v byte).

提交回复
热议问题