How to get an InputStream from a BufferedImage?

前端 未结 3 1549
后悔当初
后悔当初 2020-12-08 00:05

How can I get an InputStream from a BufferedImage object? I tried this but ImageIO.createImageInputStream() always returns NULL

BufferedImage bigImage = Grap         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-08 01:05

    If you are trying to save the image to a file try:

    ImageIO.write(thumb, "jpeg", new File(....));
    

    If you just want at the bytes try doing the write call but pass it a ByteArrayOutputStream which you can then get the byte array out of and do with it what you want.

提交回复
热议问题