I saw a thread on converting a BufferedImage to an array of pixels/bytes. Using getRGB directly on the image works, but is not ideal as it is too slow to gather all pixels. I tried the alternate way of simply grabbing the pixel data.
//convert canvas to bufferedimage
BufferedImage img = new BufferedImage(500, 500, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g2 = img.createGraphics();
canvas.printAll(g2);
g2.dispose();
System.out.println(img.getRGB(0, 0)); //-16777216 works but not ideal
byte[] pixels = ((DataBufferByte) img.getRaster().getDataBuffer()).getData();
for(byte b : pixels){
System.out.println(b); //all 0 doesnt work
}
However, the whole byte array seems to be empty (filled with 0s).