OSDN Git Service

First commitment for the BlackTank LPC1769.
[blacktank/blacktank.git] / bmplowio.h
1 /**\r
2  * @file bmplowio.h\r
3  * @author Shinichiro Nakamura\r
4  * @brief BMPファイルを少ないメモリでI/Oできるモジュールの定義。\r
5  */\r
6 \r
7 /*\r
8  * ===============================================================\r
9  *  BMP Low I/O Module\r
10  *  Version 0.0.1\r
11  * ===============================================================\r
12  * Copyright (c) 2010-2011 Shinichiro Nakamura\r
13  *\r
14  * Permission is hereby granted, free of charge, to any person\r
15  * obtaining a copy of this software and associated documentation\r
16  * files (the "Software"), to deal in the Software without\r
17  * restriction, including without limitation the rights to use,\r
18  * copy, modify, merge, publish, distribute, sublicense, and/or\r
19  * sell copies of the Software, and to permit persons to whom the\r
20  * Software is furnished to do so, subject to the following\r
21  * conditions:\r
22  *\r
23  * The above copyright notice and this permission notice shall be\r
24  * included in all copies or substantial portions of the Software.\r
25  *\r
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r
28  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r
30  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r
31  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
32  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r
33  * OTHER DEALINGS IN THE SOFTWARE.\r
34  * ===============================================================\r
35  */\r
36 \r
37 #ifndef BMPLOWIO_H\r
38 #define BMPLOWIO_H\r
39 \r
40 #include <kernel.h>\r
41 #include <t_stdlib.h>\r
42 \r
43 #define BMP_FILE_MAGIC_TEXT    (('B' << 0) | ('M' << 8))\r
44 \r
45 typedef struct bmp_file {\r
46     uint16_t bfType;\r
47     uint32_t bfSize;\r
48     uint16_t bfReserved1;\r
49     uint16_t bfReserved2;\r
50     uint32_t bfOffBits;\r
51 } bmp_file_t;\r
52 \r
53 typedef struct bmp_info {\r
54     uint32_t biSize;\r
55     uint32_t biWidth;\r
56     uint32_t biHeight;\r
57     uint16_t biPlanes;\r
58     uint16_t biBitCount;\r
59     uint32_t biCompression;\r
60     uint32_t biSizeImage;\r
61     uint32_t biXPelsPerMeter;\r
62     uint32_t biYPelsPerMeter;\r
63     uint32_t biClrUsed;\r
64     uint32_t biClrImportant;\r
65 } bmp_info_t;\r
66 \r
67 typedef struct bmp_rgbquad {\r
68     uint8_t blue;\r
69     uint8_t green;\r
70     uint8_t red;\r
71     uint8_t reserved;\r
72 } bmp_rgbquad_t;\r
73 \r
74 int bmplowio_header_init(\r
75     bmp_file_t* filehead,\r
76     bmp_info_t *infohead);\r
77 \r
78 int bmplowio_header_write(\r
79     int (*func_putc)(uint8_t c),\r
80     const bmp_file_t* filehead,\r
81     const bmp_info_t *infohead);\r
82 \r
83 int bmplowio_palette_write(\r
84     int (*func_putc)(uint8_t c),\r
85     const bmp_rgbquad_t *rgbquad,\r
86     size_t n);\r
87 \r
88 int bmplowio_image_write(\r
89     int (*func_putc)(uint8_t c),\r
90     const bmp_file_t *filehead,\r
91     const bmp_info_t *infohead,\r
92     void(*func)(int x, int y, int *r, int *g, int *b));\r
93 \r
94 int bmplowio_header_read(\r
95     int (*func_getc)(void),\r
96     bmp_file_t *filehead,\r
97     bmp_info_t *infohead);\r
98 \r
99 int bmplowio_palette_read(\r
100     int (*func_getc)(void),\r
101     bmp_rgbquad_t *rgbquad,\r
102     size_t n);\r
103 \r
104 int bmplowio_image_read(\r
105     int (*func_getc)(void),\r
106     const bmp_file_t *filehead,\r
107     const bmp_info_t *infohead,\r
108     void(*func)(int x, int y, int r, int g, int b));\r
109 \r
110 int have_palette(const bmp_info_t *infoh);\r
111 \r
112 int calc_framebytesize(const bmp_info_t *infoh);\r
113 \r
114 #endif\r
115 \r