I'm currently working my way through understanding the code of copy.c used in "whodunit" and "resize".
This loop is supposed to iterate over the scanlines of a Bitmap (by incrementing i) and within that, iterate over each pixel of the scanlines (by incrementing j).
I don't understand where the incremented values of i and j are connected to what scanline/pixel is being handled, as they are not used again int the body of the loop.
How does the program move from one line/pixel to the next?
Any Help is greatly appreciated!
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
// skip over padding, if any
fseek(inptr, padding, SEEK_CUR);
// then add it back (to demonstrate how)
for (int k = 0; k < padding; k++)
{
fputc(0x00, outptr);
}
}