trying to get an array of every pixel of an image, why is it not working???
File img = new File("daisy.png");
BufferedImage buffImg = new BufferedImage(570, 760, BufferedImage.TYPE_INT_ARGB);
try {
buffImg = ImageIO.read(img);
}
catch (IOException e) { }
int[][] pixelArray = new int[570][760];
pixelArray = get2DPixelArraySlow(buffImg);File img = new File("daisy.png");
BufferedImage buffImg = new BufferedImage(570, 760, BufferedImage.TYPE_INT_ARGB);
try {
buffImg = ImageIO.read(img);
}
catch (IOException e) { }
int[][] pixelArray = new int[570][760];
pixelArray = get2DPixelArraySlow(buffImg);public static int[][] get2DPixelArraySlow(BufferedImage sampleImage) {
int width = sampleImage.getWidth();
int height = sampleImage.getHeight();
int[][] result = new int[height][width];
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
// System.out.println(row);
// System.out.println(col);
result[row][col] = sampleImage.getRGB(col, row);
}
}
return result;
}public static int[][] get2DPixelArraySlow(BufferedImage sampleImage) {
int width = sampleImage.getWidth();
int height = sampleImage.getHeight();
int[][] result = new int[height][width];
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
// System.out.println(row);
// System.out.println(col);
result[row][col] = sampleImage.getRGB(col, row);
}
}
return result;
}when i print pixelArray its just many many 0's. the image file daisy.png is in the same folder as app.java