typedef struct tagFileheader
{
unsigned short Type; // 00h File Type Identifier to check if the file is bmp or not
unsigned int FileSize; // 02h Size of bmp file No.of bytes of the bitmap file
unsigned int PxOffset; // 0Ah Offset to bitmap pixel data
}Fileheader;
Fileheader filehdr;
Fileheader *pFileheader = &filehdr;
unsigned short Get16U(unsigned int *x)
{
unsigned short temp;
temp = *x & (0xFFFF);
return temp;
}
unsigned int Get32U(unsigned int *x)
{
unsigned int temp;
temp = *x ;
return temp;
}
int Get32(unsigned int *x)
{
int temp;
temp = *x ;
return temp;
}
void main()
{
unsigned int headersize,i ;
bAddress = fopen("D:/Tapan/Projects/Jacquard/BMP/03Body.bmp","rb"); // open the file and send the start address of its memory location
pFileheader->Type = Get16U(bAddress); // save the first two bytes of bmp file data
(char*)bAddress++;
(char*)bAddress++; // increment the address by 2 bytes to reach address of "Filesize" parameter
if(pFileheader->Type == bmpSIGNATURE) // read further bytes of the FILE header and INFO header only if the file is a bitmap
{
pFileheader->FileSize = Get32U(bAddress); // save the filesize
bAddress = bAddress + 2; // increment the address by 8 bytes to reach address of "offset" parameter
pFileheader->PxOffset = Get32U(bAddress); // save the offset
bAddress++; // increment the address by 4 bytes to reach address of "info header size" parameter
}
}
Here is my code. My main intention in this code is to read the bmp file header.I want to declare a pointer which will hold the start address of the buffer which will be created by fopen().And using that start address i will read the data from buffer. I am using this code in ARM controller. This is not the full code.
Before main i have declared bAddress globally as -
unsigned int *bAddress
When i compile the code i get following error -- a value of type "int" cannot be assigned to an entity of type "unsigned int*' Now mY question is that,is my pointer declaration correct? I have seen FILE being used to declare a pointer variable for fopen() How should i use FILE here.How should i declare the structure of FILE