Difference between revisions of "Aufgaben:Exercise 5.8: BMP Format"
(18 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | {{quiz-Header|Buchseite= | + | {{quiz-Header|Buchseite=Digital_Signal_Transmission/Applications_for_Multimedia_Files |
}} | }} | ||
− | [[File:P_ID1855__Dig_A_5_8a.png|right|frame| | + | [[File:P_ID1855__Dig_A_5_8a.png|right|frame|Photo "Sunset"]] |
− | + | A bitmap is an image format in which the individual pixels (of <i>Picture Elements</i> ) are stored in matrix form. The header of such a BMP file contains at least 54 bytes, consisting of the file header (in hexadecimal representation from 0x00 to 0x0D) as well as the information block starting from 0x0E. This is followed by the image data, in the case of color images with the color components R – G – B. | |
− | + | The following hexdump describes the photo "Sunset.bmp". Shown are the first and last 96 of the total 176456 bytes in hexadecimal representation. | |
− | [[File:P_ID1857__Dig_A_5_8b_version2.png|center|frame|Hexdump | + | [[File:P_ID1857__Dig_A_5_8b_version2.png|center|frame|Hexdump for Sunset.bmp]] |
− | + | The '''file header''' contains the following information (the prefix "0x" indicates the hexadecimal representation): | |
− | * 0x00 ... 0x01 (2 | + | * 0x00 ... 0x01 (2 bytes) BMP identifier: 0x 42 4D ⇒ "BM", |
− | * 0x02 ... 0x05 (4 | + | * 0x02 ... 0x05 (4 bytes) file size in bytes, |
− | * 0x06 ... 0x09 (5 | + | * 0x06 ... 0x09 (5 bytes) reserved (must always be assigned 0), |
− | * 0x0A ... 0x0D (4 | + | * 0x0A ... 0x0D (4 bytes) offset (start of image data). |
− | + | These specifications are only valid for the Intel processor, which reads according to the <i>little–endian byte order</i> from the least significant byte (LSB) to the most significant byte (MSB). The order "48 B1 02 00" of bytes 2 to 5 is therefore to be interpreted as "0x 00 02 B1 48", which corresponds to the decimal number 176456. | |
− | + | The '''40 byte information block''' contains the following values: | |
− | * 0x0E ... 0x11 (4 | + | * 0x0E ... 0x11 (4 bytes) length of the info block, |
− | * 0x12 ... 0x15 (4 | + | * 0x12 ... 0x15 (4 bytes) image width in pixels, |
− | * 0x16 ... 0x19 (4 | + | * 0x16 ... 0x19 (4 bytes) image height in pixels, |
− | * 0x1A ... 0x1B (2 | + | * 0x1A ... 0x1B (2 bytes) number of color planes (always set to 1), |
− | * 0x1C ... 0x1D (2 | + | * 0x1C ... 0x1D (2 bytes) bits per pixel (BPP), |
− | * 0x1E ... 0x21 (4 | + | * 0x1E ... 0x21 (4 bytes) type of data compression, |
− | * 0x22 ... 0x25 (4 | + | * 0x22 ... 0x25 (4 bytes) size of the bitmap in bytes, |
− | * 0x26 ... 0x29 (4 | + | * 0x26 ... 0x29 (4 bytes) horizontal resolution in pixels/meter, |
− | * 0x2A ... 0x2D (4 | + | * 0x2A ... 0x2D (4 bytes) vertical resolution in pixels/meter, |
− | * 0x2E ... 0x31 (4 | + | * 0x2E ... 0x31 (4 bytes) number of colors used, |
− | * 0x32 ... 0x35 (4 | + | * 0x32 ... 0x35 (4 bytes) number of important colors. |
− | |||
− | |||
− | === | + | |
+ | |||
+ | |||
+ | ''Note:'' | ||
+ | * The exercise belongs to the chapter [[Digital_Signal_Transmission/Applications_for_Multimedia_Files| "Applications for Multimedia Files"]]. | ||
+ | |||
+ | |||
+ | |||
+ | ===Questions=== | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | {Which image format has the image "Sunset.bmp"? |
|type="{}"} | |type="{}"} | ||
− | $\rm | + | $\rm width \ = \ $ { 280 } $\ \rm pixels $ |
− | $\rm | + | $\rm height \hspace{0.3cm} = \ $ { 210 } $\ \rm pixels $ |
− | { | + | {What is the color depth in "bit per pixel" $\rm (BPP)$? |
|type="{}"} | |type="{}"} | ||
− | $\rm | + | $\rm color \ depth \ = \ $ { 24 } $\ \rm BPP $ |
− | { | + | {What is the vertical resolution in "dot per inch" $\rm (dpi)$? Conversion: $1 \ {\rm inch} \approx 25.4 \ \rm mm$? |
|type="{}"} | |type="{}"} | ||
− | $\rm | + | $\rm vertical \ resolution \ = \ $ { 97 3% } $\ \rm dpi $ |
− | { | + | {How many bytes $(N_{\rm Info})$ does the information block contain here? From which byte $\rm (offset)$ does the image data start? |
|type="{}"} | |type="{}"} | ||
− | $ | + | $\rm offset \ = \ $ { 54 } $\ \rm bytes $ |
− | $\rm | + | $N_{\rm Info} \hspace{0.38cm} = \ $ { 176402 1% } $\ \rm (decimal) $ |
− | { | + | {What are the decimal values of the color components of the upper left pixel? |
|type="{}"} | |type="{}"} | ||
− | $R \ = \ $ { 40 | + | $R \ = \ $ { 40 } $\ \rm (decimal) $ |
− | $G \ = \ $ { 82 | + | $G \ = \ $ { 82 } $\ \rm (decimal) $ |
− | $B \ = \ $ { 115 | + | $B \ = \ $ { 115 } $\ \rm (decimal) $ |
</quiz> | </quiz> | ||
− | === | + | ===Solution=== |
{{ML-Kopf}} | {{ML-Kopf}} | ||
− | '''(1)''' | + | '''(1)''' The image width (in the range 0x12 ... 0x15) has the hexadecimal value 0x118 (decimal value 280). |
+ | *Correspondingly, the image height (in the range 0x16 ... 0x19) has the hexadecimal value 0x00D2 ⇒ 210 pixels. | ||
+ | *The decimal values <u>280</u> (width) and <u>210</u> (height) are to be entered in each case. | ||
+ | |||
+ | |||
+ | '''(2)''' The color depth is <u>24 BPP</u> (hexadecimal 0x18), as specified in the range 0x1C ... 0x1D. | ||
− | |||
+ | '''(3)''' The vertical resolution can be found in the range 0x2A ... 0x2D. It is 0x 0E EA = 3818 pixels per meter. | ||
+ | *With the specified length conversion, this results in 3818 · 0.0254 <u>≈ 97 dpi</u> (dots per inch). | ||
+ | *The horizontal resolution (range 0x26 ... 0x29) is similar, but not the same: 0x0EC3 ⇒ 3779 · 0.0254 ≈ 96 dpi. | ||
− | |||
− | '''(4)''' | + | '''(4)''' At 24 BPP (color depth) the information block has the minimum size 0x28 = 40d, because then no color information is given in tabular form. |
+ | *Taking into account the 14 bytes for the file header, the offset is 0x36 <u>= 54 bytes</u> (offset). The first data byte is therefore 0x36. | ||
− | + | *The size of the bitmap (in the range 0x22 ... 0x25) is 0x 02 B1 12 = 176402d. This value is smaller than the file size by <u>54</u> (file header). This value is composed as follows: | |
− | :$$280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$ | + | :$$N_{\rm Info} = 280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$ |
− | + | *Here, the "2" takes into account the two termination bytes (00 00), as can be seen from the hex dump in the information section. | |
− | '''(5)''' | + | '''(5)''' The image data are stored line by line from bottom right to top left with three bytes each. The color values of the upper left point are thus |
− | + | :: <i>R</i> = 0x28 <u>= 40d</u>, | |
− | + | :: <i>G</i> = 0x52 <u>= 82d</u>, | |
− | + | :: <i>B</i> = 0x73 <u>= 115d</u>. | |
− | + | Note here again the <i>little–endian byte order</i> of the Intel processor, so that "R – G – B" are actually arranged in the rows "B – G – R". | |
{{ML-Fuß}} | {{ML-Fuß}} | ||
− | [[Category: | + | [[Category:Digital Signal Transmission: Exercises|^5.4 Multimedia Files^]] |
Latest revision as of 13:46, 18 October 2022
A bitmap is an image format in which the individual pixels (of Picture Elements ) are stored in matrix form. The header of such a BMP file contains at least 54 bytes, consisting of the file header (in hexadecimal representation from 0x00 to 0x0D) as well as the information block starting from 0x0E. This is followed by the image data, in the case of color images with the color components R – G – B.
The following hexdump describes the photo "Sunset.bmp". Shown are the first and last 96 of the total 176456 bytes in hexadecimal representation.
The file header contains the following information (the prefix "0x" indicates the hexadecimal representation):
- 0x00 ... 0x01 (2 bytes) BMP identifier: 0x 42 4D ⇒ "BM",
- 0x02 ... 0x05 (4 bytes) file size in bytes,
- 0x06 ... 0x09 (5 bytes) reserved (must always be assigned 0),
- 0x0A ... 0x0D (4 bytes) offset (start of image data).
These specifications are only valid for the Intel processor, which reads according to the little–endian byte order from the least significant byte (LSB) to the most significant byte (MSB). The order "48 B1 02 00" of bytes 2 to 5 is therefore to be interpreted as "0x 00 02 B1 48", which corresponds to the decimal number 176456.
The 40 byte information block contains the following values:
- 0x0E ... 0x11 (4 bytes) length of the info block,
- 0x12 ... 0x15 (4 bytes) image width in pixels,
- 0x16 ... 0x19 (4 bytes) image height in pixels,
- 0x1A ... 0x1B (2 bytes) number of color planes (always set to 1),
- 0x1C ... 0x1D (2 bytes) bits per pixel (BPP),
- 0x1E ... 0x21 (4 bytes) type of data compression,
- 0x22 ... 0x25 (4 bytes) size of the bitmap in bytes,
- 0x26 ... 0x29 (4 bytes) horizontal resolution in pixels/meter,
- 0x2A ... 0x2D (4 bytes) vertical resolution in pixels/meter,
- 0x2E ... 0x31 (4 bytes) number of colors used,
- 0x32 ... 0x35 (4 bytes) number of important colors.
Note:
- The exercise belongs to the chapter "Applications for Multimedia Files".
Questions
Solution
- Correspondingly, the image height (in the range 0x16 ... 0x19) has the hexadecimal value 0x00D2 ⇒ 210 pixels.
- The decimal values 280 (width) and 210 (height) are to be entered in each case.
(2) The color depth is 24 BPP (hexadecimal 0x18), as specified in the range 0x1C ... 0x1D.
(3) The vertical resolution can be found in the range 0x2A ... 0x2D. It is 0x 0E EA = 3818 pixels per meter.
- With the specified length conversion, this results in 3818 · 0.0254 ≈ 97 dpi (dots per inch).
- The horizontal resolution (range 0x26 ... 0x29) is similar, but not the same: 0x0EC3 ⇒ 3779 · 0.0254 ≈ 96 dpi.
(4) At 24 BPP (color depth) the information block has the minimum size 0x28 = 40d, because then no color information is given in tabular form.
- Taking into account the 14 bytes for the file header, the offset is 0x36 = 54 bytes (offset). The first data byte is therefore 0x36.
- The size of the bitmap (in the range 0x22 ... 0x25) is 0x 02 B1 12 = 176402d. This value is smaller than the file size by 54 (file header). This value is composed as follows:
- $$N_{\rm Info} = 280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$
- Here, the "2" takes into account the two termination bytes (00 00), as can be seen from the hex dump in the information section.
(5) The image data are stored line by line from bottom right to top left with three bytes each. The color values of the upper left point are thus
- R = 0x28 = 40d,
- G = 0x52 = 82d,
- B = 0x73 = 115d.
Note here again the little–endian byte order of the Intel processor, so that "R – G – B" are actually arranged in the rows "B – G – R".