i a loading a 24-bit bitmap with this code but i don't know whats wrong withit?
can any one help me?
Code:
typedef unsigned long DWORD;
typedef unsigned short WORD;
typedef struct {
int Signature;
DWORD Size;
DWORD Reserved;
DWORD BitsOffset;
} BITMAP_FILEHEADER;
typedef struct {
DWORD HeaderSize;
DWORD Width;
DWORD Height;
WORD Planes;
WORD BitCount;
DWORD Compression;
DWORD SizeImage;
DWORD PelsPerMeterX;
DWORD PelsPerMeterY;
DWORD ClrUsed;
DWORD ClrImportant;
} BITMAP_HEADER;
#include <stdio.h>
main()
{
FILE * fp;
BITMAP_FILEHEADER bmpheader;
BITMAP_HEADER bmpinfheader;
int raw_data_size;
char *pixel;
//openning file
fp=fopen("c:\\pic.bmp","rb");
/*if(fp==NULL){
printf("error in opennig file");
exit(1);
}*/
fread(&bmpheader,sizeof(bmpheader),1,fp);//reads the header
fread(&bmpinfheader,sizeof(bmpinfheader),1,fp);//reads the info header
raw_data_size=bmpheader.SizeImage;//stores the size of raw bitmaps
pixel=new char [raw_data_size];//create an array for holding the pixels
fread(pixel,sizeof(char),raw_data_size,fp);//reads them from memory to aray
printf("%x",bmpheader.Signature);//prints 424D
fclose(fp);
return 0;
}