Schrift. TODO?: Umlaute
[hackover2013-badge-firmware.git] / drivers / displays / tft / bmp.h
1 /**************************************************************************/
2 /*!
3 @file bmp.h
4 @author K. Townsend (microBuilder.eu)
5
6 @section LICENSE
7
8 Software License Agreement (BSD License)
9
10 Copyright (c) 2010, microBuilder SARL
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 /**************************************************************************/
36 #ifndef __BMP_H__
37 #define __BMP_H__
38
39 #include "projectconfig.h"
40
41 /**************************************************************************
42 Windows Bitmap File Format
43 -----------------------------------------------------------------------
44 Windows bitmap images are relatively easy to work with because the
45 format is basic and requires limited overhead to work with (in
46 practice, image data is very rarely compressed). Bitmap files have
47 the following structure:
48
49 --------------------------
50 | Header | 14 bytes
51 |-------------------------
52 | Info Header | 40 bytes
53 -----------------------
54 | Palette (optional) |
55 |-------------------------
56 | Image Data |
57 --------------------------
58
59 For more information on the bitmap file format, see:
60 http://local.wasp.uwa.edu.au/~pbourke/dataformats/bmp/
61
62 **************************************************************************/
63
64
65 /**************************************************************************/
66 /*!
67 @brief 14-byte Windows bitmap header
68 */
69 /**************************************************************************/
70 typedef struct
71 {
72 uint16_t type; /* Magic identifier */
73 uint32_t size; /* File size in bytes */
74 uint16_t reserved1;
75 uint16_t reserved2;
76 uint32_t offset; /* Offset to image data, bytes */
77 } bmp_header_t;
78
79 /**************************************************************************/
80 /*!
81 @brief 40-byte Windows bitmap info header
82 */
83 /**************************************************************************/
84 typedef struct
85 {
86 uint32_t size; /* Header size in bytes */
87 int32_t width; /* Width of the image */
88 int32_t height; /* Height of image */
89 uint16_t planes; /* Number of colour planes */
90 uint16_t bits; /* Bits per pixel */
91 uint32_t compression; /* Compression type */
92 uint32_t imagesize; /* Image size in bytes */
93 int32_t xresolution; /* Pixels per meter */
94 int32_t yresolution; /* Pixels per meter */
95 uint32_t ncolours; /* Number of colours */
96 uint32_t importantcolours; /* Important colours */
97 } bmp_infoheader_t;
98
99 /**************************************************************************/
100 /*!
101 @brief Describes the different compression methods available in
102 Windows bitmap images, though compression is not currently
103 supported by this code.
104 */
105 /**************************************************************************/
106 typedef enum
107 {
108 BMP_COMPRESSION_NONE = 0,
109 BMP_COMPRESSION_RLE8 = 1,
110 BMP_COMPRESSION_RLE4 = 2,
111 BMP_COMPRESSION_RGBMASK = 3
112 } bmp_compression_t;
113
114 /**************************************************************************/
115 /*!
116 @brief 24-bit pixel data
117 */
118 /**************************************************************************/
119 typedef struct
120 {
121 uint8_t rgbBlue; /* Blue value */
122 uint8_t rgbGreen; /* Green value */
123 uint8_t rgbRed; /* Red value */
124 } bmp_rgbdata_t;
125
126 /**************************************************************************/
127 /*!
128 @brief Error return codes when processing bitmap images
129 */
130 /**************************************************************************/
131 typedef enum
132 {
133 BMP_ERROR_NONE = 0,
134 BMP_ERROR_SDINITFAIL = 1,
135 BMP_ERROR_FILENOTFOUND = 2,
136 BMP_ERROR_UNABLETOCREATEFILE = 3,
137 BMP_ERROR_NOTABITMAP = 10, /* First two bytes of the image not 'BM' */
138 BMP_ERROR_INVALIDBITDEPTH = 11, /* Image is not 24-bits */
139 BMP_ERROR_COMPRESSEDDATA = 12, /* Image contains compressed data (not supported) */
140 BMP_ERROR_INVALIDDIMENSIONS = 13, /* Image is > CFG_TFTLCD_WIDTH pixels wide or > CFG_TFTLCD_HEIGHT pixels high */
141 BMP_ERROR_PREMATUREEOF = 14 /* EOF reached unexpectedly in pixel data */
142 } bmp_error_t;
143
144 bmp_error_t bmpDrawBitmap(uint16_t x, uint16_t y, const char* filename);
145
146 #if defined CFG_SDCARD_READONLY && CFG_SDCARD_READONLY == 0
147 bmp_error_t bmpSaveScreenshot(const char* filename);
148 #endif
149
150 #endif
This page took 0.089572 seconds and 5 git commands to generate.