© 2026 Hedgehog Software, LLC
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; }
Join the Discord to ask follow-up questions and connect with the community
We are a Community full of Java developers. Connect with other devs, get help, help others and do much more!
27,739 Members