Crop camera preview for TextureView

后端 未结 6 450
借酒劲吻你
借酒劲吻你 2020-12-05 00:32

I have a TextureView with a fixed width and height and I want to show a camera preview inside of it. I need to crop the camera preview so that it doesn\'t look stretched ins

6条回答
  •  抹茶落季
    2020-12-05 01:13

    you could manipulate the byte[] data from onPreview().

    I think you'll have to:

    • put it in an Bitmap
    • do the cropping in the Bitmap
    • do a little stretching/resizing
    • and pass the Bitmap to your SurfaceView

    This is not a very performant way. Maybe you can manipulate the byte[] directly, but you will have to deal with picture formats like NV21.

提交回复
热议问题