开发者

Java type that represents a PNG image?

What is a Java type which can hold a PNG implement and prov开发者_如何学Pythonide access to it's pixel buffer?


BufferedImage img = ImageIO.read(new File("my.png"));
int color = img.getRGB(23,12);


I would take a look at Java Advanced Imaging, it handle multiple types of image files.


Take a look ImageIO and its numerous static helpers for reading and writing bytes/streams containing an image.


If you want to do pixel based operations on the entire image, I've found calling the getRGB() method every time to be fairly slow. In that case, you might want to try and get access to the actual pixel array holding the image data using something like:

byte[] pixel_array = ((DataBufferByte)img.getRaster().getDataBuffer()).getData()

There may be a more flexible way that doesn't make any presumptions on the array data type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜