问题描述
我正在尝试执行此处建议的操作:Converting Image to Color array
我复制的代码:
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();
}
我在代码中将“image.png”更改为“BA 0091.jpg”。
代码:
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();
}
}
}
我遇到的错误:
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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)