3
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 

What are the values of width and height?

Tone
  • 1,701
  • 1
  • 17
  • 18
Alejandro Diego
  • 101
  • 1
  • 7

1 Answers1

3

According to 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)

With the bitmap header you posted, the width and height would be

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

The Wikipedia link above states that

All of the integer values are stored in little-endian format (i.e. least-significant byte first).

If my understanding is correct, that converts to

 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
Tone
  • 1,701
  • 1
  • 17
  • 18
  • Why multiply with 256? – Srdjan M. May 02 '18 at 13:27
  • 2
    Each of width and height are a 4 byte integer. 8 bits per byte so 2^8 (256) possible values for each byte. So basically it's a base 256 integer (with the bytes in reverse order due to being little endian). So e.g. in base 10, the number 1250 can be represented as 0 + 5x10 + 2x10^2 + 1x10^3. In the base 256 little endian integer the first byte is 0-255, the second byte is the number of full 256's, etc. – Tone May 03 '18 at 06:51