I'm mentally blocked and I was wondering if anyone would take a look at my code and give me a pedagogical clue?
I am struggling to get the correct colour output in my resized.bmp; there have been various problems but the current situation is a correctly resized small.bmp that is completely green. In the last couple of coding iterations I have lost the check50 pass for not resizing when the factor is 1, but I suppose that is incidental at this point.
The relevant code (I hope):
// determine padding for scanlines
int scan_padding = (4 - (bi_infile.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi_infile.biHeight); i < biHeight; i++)
{
// vertical resize factoring
for ( int j = 1; j <= factor; j++ )
{
// iterate over pixels in scanline
for ( int k = 0; k < bi_infile.biWidth; k++ )
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to outfile
for ( int l = 0; l < factor; l ++ )
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// skip over padding, if any
fseek(inptr, scan_padding, SEEK_CUR);
// add padding for resized image
for (int m = 0; m < resizedPadding; m++)
{
fputc(0x00, outptr);
}
if (j < factor)
{
fseek(inptr, -bi_infile.biWidth * sizeof(RGBTRIPLE) - scan_padding, SEEK_CUR);
}
}
}