2

我需要知道如何在 java 中从加载的图像中获取字节数组。BufferedImage 似乎没有提供任何产生字节数组的方法,那么我应该使用什么呢?

4

1 回答 1

2
BufferedImage bufferedImage; //assumed that you have created it already
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ImageIO.write(bufferedImage,"jpg", byteStream);
byte[] byteArray = byteStream.toByteArray();
于 2009-08-29T20:14:10.710 回答