I was trying to do what was proposed here: Converting Image to Color array
The code that I copied:
BufferedImage bi = ImageIO.read( new File( "image.png" ) );
int[] data = ( (DataBufferInt) bi.getRaster().getDataBuffer() ).getData();
for ( int i = 0 ; i < data.length ; i++ ) {
Color c = new Color(data[i]);
// RGB is now accessible as
c.getRed();
c.getGreen();
c.getBlue();
}
I changed "image.png" to "BA 0091.jpg" in my code.
Code:
public class BANCPU{
public static void main(String[] Ugh){
BufferedImage bi = ImageIO.read( new File( "BA 0091.jpg" ) );
int[] data = ( (DataBufferInt) bi.getRaster().getDataBuffer() ).getData();
for ( int i = 0 ; i < data.length ; i++ ) {
Color c = new Color(data[i]);
// RGB is now accessible as
c.getRed();
c.getGreen();
c.getBlue();
}
}
}
Errors that I got:
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: class BufferedImage
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: variable ImageIO
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: class File
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 4]
Error: cannot find symbol
symbol: class DataBufferInt
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 6]
Error: cannot find symbol
symbol: class Color
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 6]
Error: cannot find symbol
symbol: class Color
location: class BANCPU