Writing Bitmap Files
I'm having a problem writing the code for writing a .bmp file. What I'm trying to do right now is load a bitmap then use that same information and write it into another file. The problem is, the first 10 lines or so of pixels in the image I write ends up completely black... I need help =/. Here's the code I'm using.
I can't understand why this makes the first 10 lines completely black...
BITMAPINFOHEADER bmpiheader;//Info header
BITMAPFILEHEADER bmpfheader;//File header
unsigned int bbuffer; //holds the image (64x32x32bit)
FILE *fptr; //file pointer
fptr=fopen("first.bmp","rb"); //opens original bitmap in binary
//Reads the header information into the headers
//Reads the image into bbuffer
fclose(fptr); //closes file pointer
fptr=fopen("new.bmp,"wb");//makes new .bmp file for bin writing
//writes in the headers I got from the other file
//writes in the image information from the other image
fclose(fptr); //closes file
I figured out the problem - the bmp file was a 24-bit image, but I was treating it as a 32bit (unsigned int). I just changed my unsigned int bbuffer to unsigned char bbuffer (chars are 8 bit, 3 of them make 24 bit) and now it works. YAY.