您的位置:首页 > 编程语言

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

2017-12-02 14:40 351 查看

.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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐