I have resized horizontally successfully but am having trouble with vertical resizing. I have done a header check against the staff headers and they are the same so I don't think the problem is there. I've been running my code on smiley because it's a bit easier to see what is going wrong. It seems like my code is printing the entire smiley in each row. I have looked at this so many times and moved the fseek around and I think I am going in circles. It took so much effort to get to this point I feel like I can't see the forest for the trees anymore. Any guidance on what to focus on would be appreciated.
// for each row (iterate over infile's scanlines)
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// for n-1 times
for (int copyrows = 0; copyrows <= n; copyrows++)
{
// for each pixel in row (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);
// copy pixels along each row
for (int l = 0; l < n; l++)
{
// write pixel to outfile n times
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// write outfile's padding
for (int k = 0; k < paddingresize; k++)
{
fputc(0x00, outptr);
}
// send infile cursor back to the beginning of the scanline
if (copyrows < (n - 1))
{
fseek(inptr, - ((bi.biWidth * sizeof(RGBTRIPLE)) + padding), SEEK_CUR);
}
}
// skip over infile padding, if any
fseek(inptr, padding, SEEK_CUR);
}