tags:

views:

133

answers:

4

What is a Java type which can hold a PNG implement and provide access to it's pixel buffer?

+3  A: 

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

MarkPowell
+1  A: 

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

mP
+13  A: 
BufferedImage img = ImageIO.read(new File("my.png"));
int color = img.getRGB(23,12);
Jonathan Feinberg
+1  A: 

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.

Stew