3 * @author Shinichiro Nakamura
4 * @brief 小規模組み込みシステム向けBMP I/Oの実装。
8 * ===============================================================
11 * ===============================================================
12 * Copyright (c) 2010-2011 Shinichiro Nakamura
14 * Permission is hereby granted, free of charge, to any person
15 * obtaining a copy of this software and associated documentation
16 * files (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use,
18 * copy, modify, merge, publish, distribute, sublicense, and/or
19 * sell copies of the Software, and to permit persons to whom the
20 * Software is furnished to do so, subject to the following
23 * The above copyright notice and this permission notice shall be
24 * included in all copies or substantial portions of the Software.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
28 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
30 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
31 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33 * OTHER DEALINGS IN THE SOFTWARE.
34 * ===============================================================
43 * @brief BMP画像ハンドラの実装。
46 int w; /**< 画像横方向サイズ。 */
47 int h; /**< 画像縦方向サイズ。 */
48 void (*func_pixel_write)(const int x, const int y, const uint8_t r, const uint8_t g, const uint8_t b, void *extobj_pixel_write);
49 void *extobj_pixel_write;
50 void (*func_pixel_read)(const int x, const int y, uint8_t *r, uint8_t *g, uint8_t *b, void *extobj_pixel_read);
51 void *extobj_pixel_read;
54 #define BMPIMG_GET_W(BMPIMG) ((BMPIMG)->w)
55 #define BMPIMG_GET_H(BMPIMG) ((BMPIMG)->h)
62 unsigned char r; /**< 赤。 */
63 unsigned char g; /**< 緑。 */
64 unsigned char b; /**< 青。 */
67 #define BMPIMG_FONT_DOT_WIDTH (5) /**< フォントの横方向ドット数。 */
68 #define BMPIMG_FONT_DOT_HEIGHT (7) /**< フォンとの縦方向ドット数。 */
78 #define BMPIMG_SET_COLOR(COL, R, G, B) do { (COL).r = (unsigned char)(R); (COL).g = (unsigned char)(G); (COL).b = (unsigned char)(B); } while (0)
88 #define BMPIMG_GET_STRING_WIDTH(SIZE, NSTR) \
89 ((((SIZE) * (BMPIMG_FONT_DOT_WIDTH + 1)) * ((NSTR) - 1)) + ((SIZE) * (BMPIMG_FONT_DOT_WIDTH)))
98 #define BMPIMG_GET_STRING_HEIGHT(SIZE) \
99 ((SIZE) * (BMPIMG_FONT_DOT_HEIGHT))
102 * @brief BMP画像をオープンする。
104 * @param p BMP画像ハンドラ。
107 * @param func_pixel_write ピクセル書き込み関数。
108 * @param extobj_pixel_write ピクセル書き込み関数に渡すパラメータ。
109 * @param func_pixel_read ピクセル読み込み関数。
110 * @param extobj_pixel_read ピクセル読み込み関数に渡すパラメータ。
116 void (*func_pixel_write)(const int x, const int y, const uint8_t r, const uint8_t g, const uint8_t b, void *extobj_pixel_write),
117 void *extobj_pixel_write,
118 void (*func_pixel_read)(const int x, const int y, uint8_t *r, uint8_t *g, uint8_t *b, void *extobj_pixel_read),
119 void *extobj_pixel_read);
124 * @param p BMP画像ハンドラ。
134 int bmpimg_draw_box(bmpimg_t *p, const int x1, const int y1, const int x2, const int y2, bmpcol_t *color);
139 * @param p BMP画像ハンドラ。
149 int bmpimg_fill_box(bmpimg_t *p, const int x1, const int y1, const int x2, const int y2, bmpcol_t *color);
154 * @param p BMP画像ハンドラ。
155 * @param x 横方向描画開始ピクセル位置。
156 * @param y 縦方向描画開始ピクセル位置。
157 * @param size 1ピクセルのサイズ。
161 int bmpimg_draw_string(bmpimg_t *p, const int x, const int y, const int size, const char *text, bmpcol_t *color);
166 * @param p BMP画像ハンドラ。
176 int bmpimg_draw_line(bmpimg_t *p, const int x1, const int y1, const int x2, const int y2, bmpcol_t *color);
181 * @param p BMP画像ハンドラ。
189 int bmpimg_draw_pixel(bmpimg_t *p, const int x, const int y, bmpcol_t *color);
192 * @brief チェックボックスを描画する。
194 * @param p BMP画像ハンドラ。
205 void bmpimg_draw_checkbox(
215 * @brief プログレスバーを描画する。
217 * @param p BMP画像ハンドラ。
230 void bmpimg_draw_progressbar(
242 * @brief BMPファイルから読み込む。
244 * @param p BMP画像ハンドラ。
245 * @param filename ファイル名。
252 int (*func_fread)(void *buf, const uint32_t size, void *extobj_func_fread),
253 void *extobj_func_fread);
256 * @brief BMPファイルに書き込む。
258 * @param p BMP画像ハンドラ。
259 * @param filename ファイル名。
264 int bmpimg_bmp_write(
266 int (*func_fwrite)(const void *buf, const uint32_t size, void *extobj_func_fwrite),
267 void *extobj_func_fwrite);
270 * @brief BMP画像をクローズする。
277 int bmpimg_close(bmpimg_t *p);