I've got resize working to the point where it resizes horizontally, but not vertically. Here is the code:
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(old_biHeight); i < biHeight; i++)
{
//LONG cur_pos = ftell(inptr);
for (int x = 0; x < nFactor; x++)
{
// iterate over pixels in scanline
for (int j = 0; j < old_biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for (int v = 0; v < nFactor; v++)
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
// skip over padding, if any
fseek(inptr, old_padding, SEEK_CUR);
// add the new padding
for (int k = 0; k < new_padding; k++)
{
fputc(0x00, outptr);
}
}
//fseek(inptr, cur_pos, SEEK_CUR);
}
}
I've gone over this about half a dozen times on paper and in GDB, but I can't see what's wrong. I thought that the 2nd for loop (x < nFactor) would take care of repeating the line as long as I fseek() back to the beginning at the end of that loop, but apparently I'm wrong. The image just comes out wrong when I un-comment both the ftell() and fseek() lines - its the right size, but the pixels are all messed up.
Any advice on how to tackle this?