I'm having difficulty setting the bfSize and biSizeImage header values. I should have the correct formulas for both values, however when I write either value to the output file I lose the leftmost byte. The problem may have to do with the fputc() function expecting an unsigned char.
Below is the code and some temporary print statements which output the hex values of biSizeImage and bfSize:
// set bitmap width of output file int outBiWidth = inBiWidth * factor; fseek(outptr, 18, SEEK_SET); fputc(outBiWidth, outptr); // set bitmap height of output file int outBiHeight = inBiHeight * factor; fseek(outptr, 22, SEEK_SET); fputc(outBiHeight, outptr); // set bitmap image size of output file int outBiSizeImage = ((outBiWidth * sizeof(RGBTRIPLE)) + outpadding) * abs(outBiHeight); fseek(outptr, 34, SEEK_SET); fputc(outBiSizeImage, outptr); printf("Out Image Size: %x\n", outBiSizeImage); // set file size of output file int outBfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + outBiSizeImage; fseek(outptr, 2, SEEK_SET); fputc(outBfSize, outptr); printf("Out File Size: %x\n", outBfSize);
When I execute resize, the print statements show the correct hex values, however the comparison between the output file and the staff's file tells a different story:
Help is much appreciated, thanks!