So I've been watching TheChernoProject's 2d game development series in Java, and I'm up to episode 9. I've been understanding everything in the series so far, however I can't seem to wrap my head around the BufferedImage and pixels array.
(link to episode: https://www.youtube.com/watch?v=HwUnMy_pR6A)
I don't understand how the pixels array relates to the BufferedImage object. From what I understand, when you start the program, you create a BuferredImage called image, then you copy the data from each pixel in that image into the array called pixels using
public int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
But at no point do you put the data from pixels back into that image, so how does
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
draw the data from the pixels array to the screen? I would expect it would just draw a black image.