]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained_IAR_Keil/libboard_samv7-ek/include/bmp.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained_IAR_Keil / libboard_samv7-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 #pragma pack( 1 )\r
52 \r
53 /** BMP (Windows) Header Format */\r
54 typedef struct _BMPHeader\r
55 {\r
56     /*  signature, must be 4D42 hex */\r
57     uint16_t type;\r
58     /*  size of BMP file in bytes (unreliable) */\r
59     uint32_t fileSize;\r
60     /*  reserved, must be zero */\r
61     uint16_t reserved1;\r
62     /*  reserved, must be zero */\r
63     uint16_t reserved2;\r
64     /*  offset to start of image data in bytes */\r
65     uint32_t offset;\r
66     /*  size of BITMAPINFOHEADER structure, must be 40 */\r
67     uint32_t headerSize;\r
68     /*  image width in pixels */\r
69     uint32_t width;\r
70     /*  image height in pixels */\r
71     uint32_t height;\r
72     /*  number of planes in the image, must be 1 */\r
73     uint16_t planes;\r
74     /*  number of bits per pixel (1, 4, 8, 16, 24, 32) */\r
75     uint16_t bits;\r
76     /*  compression type (0=none, 1=RLE-8, 2=RLE-4) */\r
77     uint32_t compression;\r
78     /*  size of image data in bytes (including padding) */\r
79     uint32_t imageSize;\r
80     /*  horizontal resolution in pixels per meter (unreliable) */\r
81     uint32_t xresolution;\r
82     /*  vertical resolution in pixels per meter (unreliable) */\r
83     uint32_t yresolution;\r
84     /*  number of colors in image, or zero */\r
85     uint32_t ncolours;\r
86     /*  number of important colors, or zero */\r
87     uint32_t importantcolours;\r
88 \r
89 } BMPHeader;\r
90 \r
91 #pragma pack()\r
92 \r
93 /*------------------------------------------------------------------------------\r
94  *         Exported functions\r
95  *------------------------------------------------------------------------------*/\r
96 extern uint8_t BMP_IsValid(void *file);\r
97 extern uint32_t BMP_GetFileSize(void *file);\r
98 extern uint8_t BMP_Decode( void *file, uint8_t *buffer, uint32_t width, uint32_t height, uint8_t bpp );\r
99 extern void WriteBMPheader( uint32_t* pAddressHeader, uint32_t  bmpHSize, uint32_t  bmpVSize, uint8_t nbByte_Pixels );\r
100 extern void BMP_displayHeader(uint32_t* pAddressHeader);\r
101 extern void RGB565toBGR555( uint8_t *fileSource, uint8_t *fileDestination, uint32_t width, uint32_t height, uint8_t bpp );\r
102 \r
103 #endif //#ifndef BMP_H\r
104 \r