如何从此文件头计算位图的宽度和高度?

时间:2016-06-11 06:43:34

标签: image bitmap graphic

00000000 42 4D 3A FE 05 00 00 00-00 00 36 04 00 00 28 00
00000010 00 00 D1 02 00 00 1D 02-00 00 01 00 08 00 00 00 
00000020 00 00 04 FA 05 00 13 0B-00 00 13 0B 00 00 00 00 

宽度和高度的值是多少?

1 个答案:

答案 0 :(得分:2)

根据Wikipedia - BMP file format

Offset (hex)    Offset (dec)    Size (bytes)    Windows BITMAPINFOHEADER[1]
0E              14              4               the size of this header (40 bytes)
12              18              4               the bitmap width in pixels (signed integer)
16              22              4               the bitmap height in pixels (signed integer)

使用您发布的位图标题,宽度和高度将为

Width:  D1 02 00 00
Height: 1D 02 00 00

上面的维基百科链接指出

  

所有整数值都以little-endian格式存储(即   最不重要的字节优先。)

如果我的理解是正确的,那就转换为

 Width = 209 + (2 x 256) + (0 x 256^2) + (0 x 256^3) = 721
Height =  29 + (2 x 256) + (0 x 256^2) + (0 x 256^3) = 541