BITMAPFILEHEADER new_bf;
BITMAPINFOHEADER new_bi;
new_bf = bf;
new_bi = bi;
new_bi.biHeight = bi.biHeight*factor;
new_bi.biWidth = bi.biWidth*factor;
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
int new_padding = (4 - (new_bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
new_bi.biSizeImage = (new_bi.biWidth *sizeof(RGBTRIPLE) + new_padding) * abs(new_bi.biHeight);
new_bf.bfSize = new_bi.biSizeImage + 54;
fwrite(&new_bf, sizeof(BITMAPFILEHEADER), 1, outptr);
fwrite(&new_bi, sizeof(BITMAPINFOHEADER), 1, outptr);
//changed to old_biheight to prevent confusion
for (int i = 0, old_biHeight = abs(bi.biHeight); i < old_biHeight; i++)
{
for (int l = 0; l<factor; l++)
{
// iterate over pixels in scanline
// columns within row
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for (int r=0; r<factor; r++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
fseek(inptr, padding, SEEK_CUR)
for (int k = 0; k < new_padding; k++)
{
fputc(0x00, outptr);
}
if (l < factor - 1)
{
fseek(inptr, -(bi.biWidth*sizeof(RGBTRIPLE)+padding), SEEK_CUR);
}
}
}
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// that's all folks
return 0;
}
Comparing values
When I put in
fseek(inptr, -(bi.biWidth*sizeof(RGBTRIPLE)+padding), SEEK_CUR);
I ended up getting this error code:
I'm not sure why I'm not getting the right output and this error code