1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2011, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
41 /** BMP magic number ('BM'). */
\r
42 #define BMP_TYPE 0x4D42
\r
44 /** headerSize must be set to 40 */
\r
45 #define BITMAPINFOHEADER 40
\r
47 /*------------------------------------------------------------------------------
\r
49 *------------------------------------------------------------------------------*/
\r
52 * In case of IAR EWARM use, we define an empty macro to turn useless GCC and MDK __attribute__ keyword
\r
54 #if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__
\r
58 /** BMP (Windows) File Header Format */
\r
59 typedef struct _BMPFileHeader
\r
61 /** signature, must be 4D42 hex */
\r
63 /** size of BMP file in bytes (unreliable) */
\r
65 /** reserved, must be zero */
\r
67 /** reserved, must be zero */
\r
69 /** offset to start of image data in bytes */
\r
73 /** BMP (Windows 2.x) Header */
\r
74 typedef struct _BMP2XHeader
\r
76 /** size of this header in bytes */
\r
78 /** image width in pixels */
\r
80 /** image height in pixels */
\r
82 /** number of color planes */
\r
84 /** number of bits per pixel */
\r
85 uint16_t bitsPerPixel;
\r
88 /** BMP (Windows 3.x) Header, 40 bytes */
\r
89 typedef struct _BMP3XHeader
\r
91 /** size of this header in bytes */
\r
93 /** image width in pixels */
\r
95 /** image height in pixels */
\r
97 /** number of color planes */
\r
99 /** number of bits per pixel */
\r
100 uint16_t bitsPerPixel;
\r
101 /** Compression methods used */
\r
102 uint32_t compression;
\r
103 /** Size of bitmap in bytes */
\r
104 uint32_t sizeOfBitmap;
\r
105 /** horizontal resolution in pixels per meter */
\r
106 int32_t xResolution;
\r
107 /** vertical resolution in pixels per meter */
\r
108 int32_t yResolution;
\r
109 /** number of colors in the image */
\r
110 uint32_t colorsUsed;
\r
111 /** minimum number of important colors */
\r
112 uint32_t colorsImportant;
\r
115 /** BMP (Windows 95, V4) Header, 108 bytes */
\r
116 typedef struct _BMP4Header
\r
118 /** size of this header in bytes */
\r
120 /** image width in pixels */
\r
122 /** image height in pixels */
\r
124 /** number of color planes */
\r
126 /** number of bits per pixel */
\r
127 uint16_t bitsPerPixel;
\r
128 /** Compression methods used */
\r
129 uint32_t compression;
\r
130 /** Size of bitmap in bytes */
\r
131 uint32_t sizeOfBitmap;
\r
132 /** horizontal resolution in pixels per meter */
\r
133 int32_t xResolution;
\r
134 /** vertical resolution in pixels per meter */
\r
135 int32_t yResolution;
\r
136 /** number of colors in the image */
\r
137 uint32_t colorsUsed;
\r
138 /** minimum number of important colors */
\r
139 uint32_t colorsImportant;
\r
141 /** Mask identifying bits of red component */
\r
143 /** Mask identifying bits of green component */
\r
144 uint32_t greenMask;
\r
145 /** Mask identifying bits of blue component */
\r
147 /** Mask identifying bits of alpha component */
\r
148 uint32_t alphaMask;
\r
149 /** Color space type */
\r
151 /** X coordinate of red endpoint */
\r
153 /** Y coordinate of red endpoint */
\r
155 /** Z coordinate of red endpoint */
\r
157 /** X coordinate of green endpoint */
\r
159 /** Y coordinate of green endpoint */
\r
161 /** Z coordinate of green endpoint */
\r
163 /** X coordinate of blue endpoint */
\r
165 /** Y coordinate of blue endpoint */
\r
167 /** Z coordinate of blue endpoint */
\r
169 /** Gamma red coordinate scale value */
\r
171 /** Gamma green coordinate scale value */
\r
172 uint32_t gammaGreen;
\r
173 /** Gamma blue coordinate scale value */
\r
174 uint32_t gammaBlue;
\r
177 /** BMP (Windows) Header Format */
\r
178 typedef struct _BMPHeader
\r
180 /* signature, must be 4D42 hex */
\r
182 /* size of BMP file in bytes (unreliable) */
\r
184 /* reserved, must be zero */
\r
185 uint16_t reserved1;
\r
186 /* reserved, must be zero */
\r
187 uint16_t reserved2;
\r
188 /* offset to start of image data in bytes */
\r
190 /* size of BITMAPINFOHEADER structure, must be 40 */
\r
191 uint32_t headerSize;
\r
192 /* image width in pixels */
\r
194 /* image height in pixels */
\r
196 /* number of planes in the image, must be 1 */
\r
198 /* number of bits per pixel (1, 4, 8, 16, 24, 32) */
\r
200 /* compression type (0=none, 1=RLE-8, 2=RLE-4) */
\r
201 uint32_t compression;
\r
202 /* size of image data in bytes (including padding) */
\r
203 uint32_t imageSize;
\r
204 /* horizontal resolution in pixels per meter (unreliable) */
\r
205 uint32_t xresolution;
\r
206 /* vertical resolution in pixels per meter (unreliable) */
\r
207 uint32_t yresolution;
\r
208 /* number of colors in image, or zero */
\r
210 /* number of important colors, or zero */
\r
211 uint32_t importantcolours;
\r
213 } BMPHeader ; // GCC
\r
215 #if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__
\r
219 /*------------------------------------------------------------------------------
\r
220 * Exported functions
\r
221 *------------------------------------------------------------------------------*/
\r
223 extern uint8_t BMP_IsValid(void *file);
\r
225 extern uint32_t BMP_GetFileSize(void *file);
\r
227 extern uint8_t BMP_Decode(
\r
232 unsigned char bpp);
\r
234 extern void WriteBMPheader(uint32_t* pAddressHeader,
\r
238 uint8_t nbByte_Pixels);
\r
240 extern void BMP_displayHeader(uint32_t* pAddressHeader);
\r
242 extern void RGB565toBGR555(
\r
243 uint8_t *fileSource,
\r
244 uint8_t *fileDestination,
\r
249 #endif //#ifndef BMP_H
\r