]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/AtmelFiles/libboard_sama5d4x-ek/include/bmp.h
Core kernel files:
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D4x_EK_IAR / AtmelFiles / libboard_sama5d4x-ek / include / bmp.h
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License \r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2011, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\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
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\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
16  *\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
28  */\r
29 \r
30 /**\r
31  *  \file\r
32  *  \section Purpose\r
33  * \r
34  *  Utility for BMP\r
35  * \r
36  */\r
37 \r
38 #ifndef BMP_H\r
39 #define BMP_H\r
40 \r
41 /**  BMP magic number ('BM'). */\r
42 #define BMP_TYPE       0x4D42\r
43 \r
44 /**  headerSize must be set to 40 */\r
45 #define BITMAPINFOHEADER   40\r
46 \r
47 /*------------------------------------------------------------------------------\r
48  *         Exported types\r
49  *------------------------------------------------------------------------------*/\r
50 \r
51 /*\r
52  * In case of IAR EWARM use, we define an empty macro to turn useless GCC and MDK __attribute__ keyword\r
53  */\r
54 #if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__\r
55 #    pragma pack( 1 )\r
56 #endif\r
57 \r
58 /** BMP (Windows) File Header Format */\r
59 typedef struct _BMPFileHeader\r
60 {\r
61     /** signature, must be 4D42 hex */\r
62     uint16_t type;\r
63     /** size of BMP file in bytes (unreliable) */\r
64     uint32_t fileSize;\r
65     /** reserved, must be zero */\r
66     uint16_t reserved1;\r
67     /** reserved, must be zero */\r
68     uint16_t reserved2;\r
69     /** offset to start of image data in bytes */\r
70     uint32_t offset;\r
71 } BMPFileHeader;\r
72 \r
73 /** BMP (Windows 2.x) Header */\r
74 typedef struct _BMP2XHeader\r
75 {\r
76     /** size of this header in bytes */\r
77     uint32_t size;\r
78     /** image width in pixels */\r
79     uint16_t width;\r
80     /** image height in pixels */\r
81     uint16_t height;\r
82     /** number of color planes */\r
83     uint16_t planes;\r
84     /** number of bits per pixel */\r
85     uint16_t bitsPerPixel;\r
86 } BMP2XHeader;\r
87 \r
88 /** BMP (Windows 3.x) Header, 40 bytes */\r
89 typedef struct _BMP3XHeader\r
90 {\r
91     /** size of this header in bytes */\r
92     uint32_t size;\r
93     /** image width in pixels */\r
94     int32_t  width;\r
95     /** image height in pixels */\r
96     int32_t  height;\r
97     /** number of color planes */\r
98     uint16_t 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
113 }  BMP3XHeader;\r
114 \r
115 /** BMP (Windows 95, V4) Header, 108 bytes */\r
116 typedef struct _BMP4Header\r
117 {\r
118     /** size of this header in bytes */\r
119     uint32_t size;\r
120     /** image width in pixels */\r
121     int32_t  width;\r
122     /** image height in pixels */\r
123     int32_t  height;\r
124     /** number of color planes */\r
125     uint16_t 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
140 \r
141     /** Mask identifying bits of red component */\r
142     uint32_t redMask;\r
143     /** Mask identifying bits of green component */\r
144     uint32_t greenMask;\r
145     /** Mask identifying bits of blue component */\r
146     uint32_t blueMask;\r
147     /** Mask identifying bits of alpha component */\r
148     uint32_t alphaMask;\r
149     /** Color space type */\r
150     uint32_t csType;\r
151     /** X coordinate of red endpoint */\r
152     int32_t  redX;\r
153     /** Y coordinate of red endpoint */\r
154     int32_t  redY;\r
155     /** Z coordinate of red endpoint */\r
156     int32_t  redZ;\r
157     /** X coordinate of green endpoint */\r
158     int32_t  greenX;\r
159     /** Y coordinate of green endpoint */\r
160     int32_t  greenY;\r
161     /** Z coordinate of green endpoint */\r
162     int32_t  greenZ;\r
163     /** X coordinate of blue endpoint */\r
164     int32_t  blueX;\r
165     /** Y coordinate of blue endpoint */\r
166     int32_t  blueY;\r
167     /** Z coordinate of blue endpoint */\r
168     int32_t  blueZ;\r
169     /** Gamma red coordinate scale value */\r
170     uint32_t gammaRed;\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
175 }  BMP4Header;\r
176 \r
177 /** BMP (Windows) Header Format */\r
178 typedef struct _BMPHeader\r
179 {\r
180     /*  signature, must be 4D42 hex */\r
181     uint16_t type;\r
182     /*  size of BMP file in bytes (unreliable) */\r
183     uint32_t fileSize;\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
189     uint32_t offset;\r
190     /*  size of BITMAPINFOHEADER structure, must be 40 */\r
191     uint32_t headerSize;\r
192     /*  image width in pixels */\r
193     uint32_t width;\r
194     /*  image height in pixels */\r
195     uint32_t height;\r
196     /*  number of planes in the image, must be 1 */\r
197     uint16_t planes;\r
198     /*  number of bits per pixel (1, 4, 8, 16, 24, 32) */\r
199     uint16_t bits;\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
209     uint32_t ncolours;\r
210     /*  number of important colors, or zero */\r
211     uint32_t importantcolours;\r
212 \r
213 } BMPHeader  ; // GCC\r
214 \r
215 #if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__\r
216 #    pragma pack()\r
217 #endif\r
218 \r
219 /*------------------------------------------------------------------------------\r
220  *         Exported functions\r
221  *------------------------------------------------------------------------------*/\r
222 \r
223 extern uint8_t BMP_IsValid(void *file);\r
224 \r
225 extern uint32_t BMP_GetFileSize(void *file);\r
226 \r
227 extern uint8_t BMP_Decode(\r
228     void *file,\r
229     uint8_t*buffer,\r
230     uint32_t width,\r
231     uint32_t height,\r
232     unsigned char bpp);\r
233 \r
234 extern void WriteBMPheader(uint32_t* pAddressHeader,\r
235                     uint32_t  bmpHSize,\r
236                     uint32_t  bmpVSize,\r
237                     uint8_t bmpRgb,\r
238                     uint8_t nbByte_Pixels);\r
239 \r
240 extern void BMP_displayHeader(uint32_t* pAddressHeader);\r
241 \r
242 extern void RGB565toBGR555(\r
243     uint8_t *fileSource,\r
244     uint8_t *fileDestination,\r
245     uint32_t width,\r
246     uint32_t height,\r
247     uint8_t bpp);\r
248 \r
249 #endif //#ifndef BMP_H\r
250 \r