【问题标题】:Getting an in-memory representation of the JPEG rendering of an Image获取图像的 JPEG 渲染的内存表示
【发布时间】:2009-08-29 19:56:23
【问题描述】:

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

【问题讨论】:

    标签: java image bytearray


    【解决方案1】:
    BufferedImage bufferedImage; //assumed that you have created it already
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    ImageIO.write(bufferedImage,"jpg", byteStream);
    byte[] byteArray = byteStream.toByteArray();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 2023-01-29
      相关资源
      最近更新 更多