linux下读取bmp图片文件头

建议先了解下BMP图片格式.

条件:

1.用windows画图工具另存的一张BMP格式图片;

2.linux或ubuntu下vim编译器

#include  
#include  
#include  

#include  
#pragma pack(2)   //对齐
using namespace std;  

typedef struct BITMAPFILEHEADER  
{   
    u_int16_t bfType;   
    u_int32_t bfSize;   
    u_int16_t bfReserved1;   
    u_int16_t bfReserved2;   
    u_int32_t bfOffBits;   
}BITMAPFILEHEADER;   

typedef struct BITMAPINFOHEADER  
{   
    u_int32_t biSize;   
    u_int32_t biWidth;   
    u_int32_t biHeight;   
    u_int16_t biPlanes;   
    u_int16_t biBitCount;   
    u_int32_t biCompression;   
    u_int32_t biSizeImage;   
    u_int32_t biXPelsPerMeter;   
    u_int32_t biYPelsPerMeter;   
    u_int32_t biClrUsed;   
    u_int32_t biClrImportant;   
}BITMAPINFODEADER;  

void showBmpHead(BITMAPFILEHEADER &pBmpHead){    
    cout<<"位图文件头:"<  


你可能感兴趣的:(Linux)