crop image directly from byte array

后端 未结 2 788
广开言路
广开言路 2021-01-02 18:27

I have a byte array, which contains an image... i\'d like to save it cropped.

My working method was: get the byte[] convert it into a bitmap with BitmapFactory.deco

相关标签:
2条回答
  • 2021-01-02 19:10

    The method decodeByteArray(dataArray, offset, length, options) is not intended to crop an image but to parse an image from a byte buffer that contains more data than the image itself. The typical use of this is to extract images from complex binary data structures that include images among other things.

    To my knowledge there is no way to crop an image without creating a new one. To me the best you can do is what you are currently doing.

    0 讨论(0)
  • 2021-01-02 19:10

    For JPEG (the ubiquitous picture format on mobile devices), it is possible to decode only some specific rectangle. This requires some discipline in writing C code on top of generic software decoder, especially if you want to do it as fast as possible, and waste not extra RAM.

    Support in libjpeg-turbo was been added five years after this question had been asked.

    0 讨论(0)
提交回复
热议问题