3 * @author Copyright(C) 2012 Shinichiro Nakamura
7 * ===============================================================
9 * ===============================================================
10 * Copyright (c) 2012 Shinichiro Nakamura
12 * Permission is hereby granted, free of charge, to any person
13 * obtaining a copy of this software and associated documentation
14 * files (the "Software"), to deal in the Software without
15 * restriction, including without limitation the rights to use,
16 * copy, modify, merge, publish, distribute, sublicense, and/or
17 * sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 * OTHER DEALINGS IN THE SOFTWARE.
32 * ===============================================================
42 int main(int argc, char **argv);
45 * @brief ストリームからデータを読み込む。
47 * インターフェースでは、何からどのように読み込むかについて一切感知していない。
48 * この関数では、何からどのように読み込むかについて解決する。
50 * @param buf バッファへのポインタ。
51 * @param size 読み込みバイトサイズ。
52 * @param extobj ユーザが指定した拡張オブジェクト。
54 int func_fread(void *buf, const unsigned int size, void *extobj)
56 FILE *fp = (FILE *)extobj;
57 return fread(buf, size, 1, fp);
61 * @brief ストリームへデータを書き込む。
63 * インターフェースでは、何にどのように書き込むかについて一切感知していない。
64 * この関数では、何にどのように書き込むかについて解決する。
66 * @param buf バッファへのポインタ。
67 * @param size 書き込みバイトサイズ。
68 * @param extobj ユーザが指定した拡張オブジェクト。
70 int func_fwrite(const void *buf, const unsigned int size, void *extobj)
72 FILE *fp = (FILE *)extobj;
73 return fwrite(buf, size, 1, fp);
76 int main(int argc, char **argv)
88 printf("lcdtool [file] [line1] [line2]\n");
97 canvas.buffer = (bmpcol_t *)malloc(sizeof(bmpcol_t) * imgw * imgh);
102 * ピクセル入出力関数を渡して初期化する。
103 * ユーザが指定可能な拡張オブジェクトに、独自に規定したキャンバスを渡しておく。
105 bmpimg_open(&bmpimg, imgw, imgh, canvas_pixel_writer, &canvas, canvas_pixel_reader, &canvas);
107 BMPIMG_SET_COLOR(col, 124, 120, 230);
108 bmpimg_fill_box(&bmpimg, 0, 0, imgw - 1, imgh - 1, &col);
110 lcdimg = lcdimg_open(8, 2);
111 for (i = 0; i < strlen(argv[2]); i++) {
112 lcdimg_text(lcdimg, i, 0, argv[2][i]);
114 for (i = 0; i < strlen(argv[3]); i++) {
115 lcdimg_text(lcdimg, i, 1, argv[3][i]);
118 lcdimg_draw(lcdimg, canvas_drawer, &canvas);
120 fp = fopen(argv[1], "wb");
122 bmpimg_bmp_write(&bmpimg, func_fwrite, fp);
126 lcdimg_close(lcdimg);
131 bmpimg_close(&bmpimg);
134 * 画像ピクセルを格納する領域を破棄する。