JAVA中BufferedImage与byte[]转换

 

BufferedImage转byte[]

 ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(imgBuff, "jpeg", out);
byte[] bytes=out.toByteArray();

 

 

byte[]转BufferedImage

ByteArrayInputStream in = new ByteArrayInputStream(bytes);
BufferedImage srcBuff = ImageIO.read(in);

 

posted @ 2021-11-11 16:41  yvioo  阅读(1957)  评论(0编辑  收藏  举报