简体   繁体   中英

Java : read an image inside a binary file (or maybe more generally, from a stream)

I am making a java program that reads a binary file, which contains multiple images (in PNG format), and some binary data.

How can i load the images (specifically, as java.awt.Image 's)? So far the only way i have found to load an image is via functions that just take a file. How can i do it from, say, an InputStream?

The ImageIO#read(InputStream) method does return a java.awt.image.BufferedImage (which extends from java.awt.Image ).

https://docs.oracle.com/javase/8/docs/api/javax/imageio/ImageIO.html#read-java.io.InputStream-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM