Reputation: 317
I am trying to convert my BufferedImage
into a integer array, but i am getting the following error: "java.awt.image.DataBufferByte
cannot be cast to java.awt.image.DataBufferInt
"
Here's my bit of code:
public class Test {
public static void main (String [] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("G.bmp"));
} catch (IOException e) { }
int[] imgarray = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
}
}
Upvotes: 0
Views: 2291
Reputation: 13139
Try this:
byte[] imgarray = ((DataBufferByte)img.getRaster().getDataBuffer()).getData();
Upvotes: 3