I tried following the pseudocode from the walk through and it compiled, however the image did not resize - rather the center filled in green. I hope my only problem is that I fail to skip over the padding at the end (I still don't completely understand the fseek and fputc functions). Does anything else stick out as glaringly incorrect:
// write new dimensiosn for BITMAPINFOHEADER
BITMAPINFOHEADER new_bi;
new_bi.biWidth = bi.biWidth * fac;
new_bi.biHeight = bi.biHeight * fac;
// determine padding for scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
int new_padding = (4 - (new_bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// write new size for BITMAPINFOHEADER
new_bi.biSizeImage = ((sizeof(RGBTRIPLE)* new_bi.biWidth) + new_padding)*abs(new_bi.biHeight);
// write new BITMAPFILEHEADER
BITMAPFILEHEADER new_BF;
new_BF.bfSize= new_bi.biSizeImage + sizeof(BITMAPINFOHEADER)+sizeof(BITMAPFILEHEADER);
// write outfile's BITMAPFILEHEADER
fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bi, sizeof(BITMAPINFOHEADER), 1, outptr);
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
//increase number of rows by a factor of fac
for (int j = 0; j < fac; j++)
{
// iterate over pixels in scanline
for (int k = 0; k < bi.biWidth; k++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for(int m=0; m < fac; m++)
{
// write RGB triple to outfile, factor times
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
}
// skip over padding, if any
fseek(inptr, padding, SEEK_CUR);
// then add it back (to demonstrate how)
for (int k = 0; k < padding; k++)
{
fputc(0x00, outptr);
}
}