How to convert array of bytes into Image in Java SE

后端 未结 5 1344
悲&欢浪女
悲&欢浪女 2020-12-09 23:07

What is the right way to convert raw array of bytes into Image in Java SE. array consist of bytes, where each three bytes represent one pixel, with each byte for correspondi

5条回答
  •  失恋的感觉
    2020-12-09 23:26

    Assuming you know the height and width of the image.

    BufferedImage img=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    for(int r=0; r

    Roughly. This assumes the pixel data is encoded as a set of rows; and that the length of colors is 3 * width * height (which should be valid).

提交回复
热议问题