Convert Byte Array to image in Java - without knowing the type

后端 未结 3 2099
轮回少年
轮回少年 2020-12-06 10:50

Sounds simple right? Use

ImageIO.read(new ByteArrayInputStream(bytes));

Here\'s the wrinkle. For some reason it is detecting a jpeg as a b

3条回答
  •  隐瞒了意图╮
    2020-12-06 11:19

    For the reference you can have a look at wikipedia, you can find the header of the different formats there.
    http://en.wikipedia.org/wiki/Graphics_Interchange_Format
    http://en.wikipedia.org/wiki/BMP_file_format
    http://en.wikipedia.org/wiki/JPEG

提交回复
热议问题