Android Camera - How can i take a specific “rectangle” from the byte array?

前端 未结 2 442
情话喂你
情话喂你 2020-12-30 10:07

I have created an application that shoots and saves photos. I have a preview and an overlay on top of that preview. The overlay defines a square (the area around the square

2条回答
  •  北海茫月
    2020-12-30 10:31

    The camera preview data comes in YUV format (specifically ImageFormat.NV21), which BitmapFactory doesn't support directly. You can use YuvImage to convert it to a Bitmap as described here. The only difference is that you'll want to pass a Rect corresponding to the square that you want when calling YuvImage.compressToJpeg.

提交回复
热议问题