I'm given a bmp and I'm trying to create a new image and output that to bmp file. I'm not sure if I'm doing it correctly.
Bmp consist of three 3structs:
Header, InfoHeader, Data
I'm able to get the Header,InfoHeader written to the file, but the data is what alludes me. I just get a black image with random lines. All the numbers such as pixeltype,size,etc all match up but the image just won't come out to the orginal. Wondering if there are any image experts that might know something? Thanks
Code:
Bool WriteImage(Image im, String filename)
{
FILE *op;
char *outname;
outname = filename;
op = fopen(outname,"w");
int s1 = fwrite((void *)&im.head,sizeof(im.head),1,op);
fflush(op);
int s2 = fwrite((void *)&im.infoheader,sizeof(im.infoheader),1,op);
fflush(op);
int s3 = fwrite((void *)&im.data,GetTotalSize(im),1, op);
fflush(op);
fclose(op);
return(s1 && s2 && s3);
}