wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 1 | /* (C) Copyright 2002 |
| 2 | * Detlev Zundel, DENX Software Engineering, dzu@denx.de. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /************************************************************************/ |
| 8 | /* ** Layout of a bmp file */ |
| 9 | /************************************************************************/ |
| 10 | |
| 11 | #ifndef _BMP_H_ |
| 12 | #define _BMP_H_ |
| 13 | |
| 14 | typedef struct bmp_color_table_entry { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 15 | __u8 blue; |
| 16 | __u8 green; |
| 17 | __u8 red; |
| 18 | __u8 reserved; |
| 19 | } __attribute__ ((packed)) bmp_color_table_entry_t; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 20 | |
| 21 | /* When accessing these fields, remember that they are stored in little |
| 22 | endian format, so use linux macros, e.g. le32_to_cpu(width) */ |
| 23 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 24 | typedef struct bmp_header { |
| 25 | /* Header */ |
| 26 | char signature[2]; |
| 27 | __u32 file_size; |
| 28 | __u32 reserved; |
| 29 | __u32 data_offset; |
| 30 | /* InfoHeader */ |
| 31 | __u32 size; |
| 32 | __u32 width; |
| 33 | __u32 height; |
| 34 | __u16 planes; |
| 35 | __u16 bit_count; |
| 36 | __u32 compression; |
| 37 | __u32 image_size; |
| 38 | __u32 x_pixels_per_m; |
| 39 | __u32 y_pixels_per_m; |
| 40 | __u32 colors_used; |
| 41 | __u32 colors_important; |
| 42 | /* ColorTable */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 43 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 44 | } __attribute__ ((packed)) bmp_header_t; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 45 | |
| 46 | typedef struct bmp_image { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 47 | bmp_header_t header; |
| 48 | /* We use a zero sized array just as a placeholder for variable |
| 49 | sized array */ |
| 50 | bmp_color_table_entry_t color_table[0]; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 51 | } bmp_image_t; |
| 52 | |
| 53 | /* Data in the bmp_image is aligned to this length */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 54 | #define BMP_DATA_ALIGN 4 |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 55 | |
| 56 | /* Constants for the compression field */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 57 | #define BMP_BI_RGB 0 |
| 58 | #define BMP_BI_RLE8 1 |
| 59 | #define BMP_BI_RLE4 2 |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 60 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 61 | #endif /* _BMP_H_ */ |