I am having problem with changing file header. Specifically:
BITMAPINFOHEADER new_bi; fread(&new_bi, sizeof(BITMAPINFOHEADER), 1, inptr); BITMAPFILEHEADER new_bf; fread(&new_bf, sizeof(BITMAPFILEHEADER), 1, inptr); //changing any necessary values new_bi.biWidth = bi.biWidth * n; new_bi.biHeight= bi.biHeight * n; int old_padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; int new_padding = (4 - (new_bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; new_bi.biSizeImage = ((sizeof(RGBTRIPLE) * new_bi.biWidth) + new_padding) * abs(new_bi.biHeight); new_bf.bfSize = new_bi.biSizeImage + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); // write outfile's BITMAPINFOHEADER fwrite(&new_bf, sizeof(BITMAPFILEHEADER), 1, outptr); fwrite(&new_bi, sizeof(BITMAPINFOHEADER), 1, outptr);
So in these lines of code, I declare new struct new_bi and new_bf belongs to BITMAPINFOHEADER and BITMAPFILEHEADER respectively, also fread() them as well.
I changed any needed value and fwrite() them into outptr file. By now it should work.
However it won't work. I got it working before, but by overwriting bi.biWidth and bi.biHeight value with *= n.
Any ideas why it just will not work this time?