您好,我想创建一个程序,它读取图像并在输出带有这样图像的 excel 后 ---> http://www.boydevlin.co.uk/images/screenshots/eascreen04.png
为了实现这一点,我认为我必须将图像中每个像素的 rgb 值读取到 ArrayList 我想按以下顺序保存它
示例 5x5px 图像
01,02,03,04,05
06,07,08,09,10
11,12,13,14,15
.......
我已经有了这个,但它不能正常工作有人可以帮我解决这个问题吗
public class Engine {
private int x = 0;
private int y = 0;
private int count = 50;
private boolean isFinished = false;
ArrayList<Color> arr = new ArrayList<Color>();
public void process(){
BufferedImage img = null;
try {
img = ImageIO.read(new File("res/images.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("img file not found");
}
while(isFinished = false){
int rgb = img.getRGB(x, y);
Color c = new Color(rgb);
arr.add(c);
System.out.println("y:"+ y);
x++;}
if(x == 49){
y++;
x = 0;
}else if(x == 49 && y == 49){
isFinished = true;
}
}
};