注:BMP文件格式在这里只做简单介绍,详细介绍可以参看我整理的这个文档<a target=_blank href="http://download.youkuaiyun.com/detail/zhangyi19930704/9262043">点击打开链接</a>
1、BMP文件格式
BMP文件主要包含四个部分:位图文件头,位图信息头,位图调色板,位图数据。
用结构体表示就是:
<span style="background-color: rgb(255, 255, 255);"><span style="font-size:18px;"></span></span><pre name="code" class="cpp"><pre name="code" class="cpp"><span style="color:#3366ff;"><span style="white-space:pre"> </span>typedef struct tagBITMAP_FILE{
<span style="white-space:pre"> </span>BMPHeader bitmapheader;
<span style="white-space:pre"> </span>BMPInfoHeader bitmapinfoheader;
<span style="white-space:pre"> </span>PALETTEENTRY palette[256];
<span style="white-space:pre"> </span>UCHAR *buffer;
<span style="white-space:pre"> </span>} BITMAP_FILE;</span>
其中位图文件头结构体为:
<span style="font-size:18px;color:#3366ff;"><span style="white-space:pre"> </span>typedef struct{
<span style="white-space:pre"> </span>short type;
<span style="white-space:pre"> </span>int size;
<span style="white-space:pre"> </span>short reserved1;
<span style="white-space:pre"> </span>short reserved2;
<span style="white-space:pre"> </span>int offset;
<span style="white-space:pre"> </span>} BMPHeade