// determine padding for scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// iterate over infile\'s scanlines
for (int i = 0, biHeight =
At the line level you should after single read of a pixel do n
writes of it. This is done by adding another inner loop. That copied pixel resides at triple
var during the operation.
At the file level you should repeatedly process single line, reading and writing it multiple times.
If your input file is on the disk, it should support rewinding. So you can read the line, write it (duplicating pixels inside, as shown above), then rewind the file to the start of the line, read the line again, write it, etc.
Try to store the file position with ftell
before reading the line, and rewind the file position to this point with fseek
each time you need to process it.