I'm trying to figure out how to finish my resize.c and am feeling pretty stuck. Right now, when I run the resize.c to change small by a factor of 4, I get a green square of the correct size (but with no white in the middle). When I take out "fseek(inptr, -(newPadding+bi_out.biWidth), SEEK_CUR);" I get something closer to the correct output - the box you see below that has a white rectangle that has been resized horizontally but not vertically.
I believe that my headers are correct and, logically, it seems like the problem would be with the for loop that is responsible for the vertical resize. Yet I'm troubled by the fact that my attempt to move back to the beginning of the horizontal line with fseek seems to make matters worse.
Any suggestions would be appreciated.
// write outfile's BITMAPFILEHEADER
fwrite(&bf_out, sizeof(BITMAPFILEHEADER), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bi_out, sizeof(BITMAPINFOHEADER), 1, outptr);
// iterate over infile's scanlines, up to the abs value of the original height
for (int i = 0; i < origHeight2; i++)
{
for (int z = 0; z<n; z++)
{
for( int j = 0; j < origWidth; j++)
{
//temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to outfile
for( int k = 0; k < n; k++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// skip over padding, if any
fseek(inptr, padding, SEEK_CUR);
//add padding back
for (int l = 0; l < newPadding; l++)
{
fputc(0x00, outptr);
}
//return to beginning of line
fseek(inptr, -(newPadding+bi_out.biWidth), SEEK_CUR);
}
}