My code is partially correct, but I have a couple of issues.
1. It does not work with small.bmp
2. I do not understand how fseek works in this program.
What is wrong, where is the mistake?
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
for (int a = 0; a < scale; a++)
{
// 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);
// write RGB triple to outfile
for (int b = 0; b < scale; b++)
{
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 < new_padding; k++)
{
fputc(0x00, outptr);
}
fseek(inptr, -(bi.biWidth * 3 + padding ), SEEK_CUR); //DO NOT UDERSTAND THIS LINE
}
fseek(inptr, bi.biWidth*3+new_padding, SEEK_CUR); //DO NOT UDERSTAND THIS LINE
}