.bmp文件格式介绍与该类型文件读取的代码实现

.bmp文件格式(之后修改)

标准Windows数据格式,而且是设备无关的bitmap(二进制文件),很少采用圧缩形式,不适合存储动画

基本结构

BITMAPFILEHEADER bmfh;
bmfh包含文件自身的信息,而不是bitmap的信息
BITMAPINFOHEADER bmih;
bmih包含bitmap的信息
RGBQUAD aColors[];
aColors是颜色表
BYTE aBitmapBits[];
bmih的结构

精确的结构

数据情况size 100x100, 256 colors, no compression
start-value以字节为单位,数据结构中的各个元素的起始位置;size-value ,数据结构中各个元素的大小,以字节为单位;purpose表示该数据结构元素的含义
BITMAPFILEHEADER
成员
name start size purpose
bfType 1 2 必须为’BM’,用于声明改文件为.bmp文件
bfSize 3 4 说明改文件的大小,以字节为单位
bfReserved1 7 2 保留至,设定为0
bfReserved2 9 2 保留至,设定为0
bfOffBits 11 4 说明位图像素内容相对于其实位置的偏移量

BITMAPINFOHEADER
biSize 15 4 说明BITMAPINFOHEADER这个数据结构的大小,标准值为40bytes
biWidth 19 用于说明图片的宽度,以像素为单位,如果为100*100的图像,则比biWidth=100

19 4 biWidth 100 specifies the width of the image, in pixels.
23 4 biHeight 100 specifies the height of the image, in pixels.
27 2 biPlanes 1 specifies the number of planes of the target device, must be set to zero.
29 2 biBitCount 8 specifies the number of bits per pixel.
31 4 biCompression 0 Specifies the type of compression, usually set to zero (no compression).
35 4 biSizeImage 0 specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.
39 4 biXPelsPerMeter 0 specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.
43 4 biYPelsPerMeter 0 specifies the the vertical pixels per meter on the designated targer device, usually set to zero.
47 4 biClrUsed 0 specifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.
51 4 biClrImportant 0 specifies the number of color that are ‘important’ for the bitmap, if set to zero, all colors are important.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值