Doubt over BufferedImage and pixel manipulation

0

I would like a more technical and in-depth explanation of what happens in this line of code (I've researched before but understood only superficially):

BufferedImage bf = new BufferedImage(Window.WIDTH,Window.HEIGHT, BufferedImage.TYPE_INT_RGB);
int [] imagem =  ((DataBufferInt)bf.getRaster().getDataBuffer()).getData();

Another question is in the question of assigning values in hexadecimal in the "image" array, for example, when using a loop as follows, assigning the color pink (0xff00ff), the entire screen is populated by pixels of the same color when using drawImage(bf,0,0, Window.WIDTH, Window.HEIGHT, null) , of class Graphics :

for(int y = 0; y < Window.HEIGHT; y++)
{
    for(int x = 0; x < Window.WIDTH; x++)
    {
        imagem[x + y * Window.WIDTH] = 0xff00ff;
    }
}

How does the array establish a relationship with the previously created BufferedImage, so that if I change something in some index it will also change the pixel of a certain position?

    
asked by anonymous 21.09.2018 / 07:03

0 answers