I would very appreciate your help.
//variables for original width and height int originalWid = bi.biWidth; int originalHei = bi.biHeight;
//update width and height
bi.biWidth = scale * originalWid;
bi.biHeight = scale * originalHei;
// determine padding for scanlines
int oldPadding = (4 - (originalWid * sizeof(RGBTRIPLE)) % 4) % 4;
int newPadding = (4 -(bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
//update image size
bi.biSizeImage = abs(bi.biHeight) * (bi.biWidth * sizeof(RGBTRIPLE)+ newPadding);
//update file size
bf.bfSize = bi.biSizeImage + bf.bfOffBits;
// 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(originalHei); i < biHeight; i++)
{ //horizontal resize
for(int s = 0; s < scale; s++)
{
//move cursor, 54 is size of header
fseek(inptr,((54 + originalWid * 3 + oldPadding) * i), SEEK_SET );
// iterate over pixels in scanline
for (int j = 0; j < originalWid; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
//write to outfile
for ( int z = 0; z < scale; z++ )
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
}
// skip over padding, if any
fseek(inptr, oldPadding, SEEK_CUR);
// then add it back (to demonstrate how)
for (int k = 0; k < newPadding; k++)
{
fputc(0x00, outptr);
}
}
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// that's all folks
return 0;
}