阅读背景:

我对这段代码感到困惑,对FILE结构和fopen函数有疑问

来源:互联网 
 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
     }
}
 typedef struct tagFileheader    
{
  unsigned 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: