diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2011-11-13 15:37:16 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2011-11-13 15:37:16 +0000 |
| commit | 9a70c42241c70e57bbe739f45d254c67bacc83e7 (patch) | |
| tree | 2387eebfd2f3ad83c5e4e69d6d39fd37f234d928 /tools | |
| parent | 61f61c97738a3f0e279b7c31f9096a5aaa977291 (diff) | |
| download | rockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.zip rockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.tar.gz rockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.tar.bz2 rockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.tar.xz | |
Add the ability to create a prefilled struct bitmap along with generated images.
This allows to directly draw generated and builtin images using lcd_bmp(bm_xxx);
Also fixes builtin list icons on non-mono targets, as they didn't have the
format field set.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30971 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/bmp2rb.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c index f9f554a..7fee1e6 100644 --- a/tools/bmp2rb.c +++ b/tools/bmp2rb.c @@ -453,19 +453,21 @@ int transform_bitmap(const struct RGBQUAD *src, int width, int height, void generate_c_source(char *id, char* header_dir, int width, int height, const unsigned short *t_bitmap, int t_width, - int t_height, int t_depth) + int t_height, int t_depth, bool t_mono, bool create_bm) { FILE *f; FILE *fh; int i, a; char header_name[1024]; + bool have_header = header_dir && header_dir[0]; + create_bm = have_header && create_bm; if (!id || !id[0]) id = "bitmap"; f = stdout; - if (header_dir && header_dir[0]) + if (have_header) { snprintf(header_name,sizeof(header_name),"%s/%s.h",header_dir,id); fh = fopen(header_name,"w+"); @@ -484,6 +486,11 @@ void generate_c_source(char *id, char* header_dir, int width, int height, else fprintf(fh, "extern const unsigned short %s[];\n", id); + if (create_bm) + { + fprintf(f, "#include \"lcd.h\"\n"); + fprintf(fh, "extern const struct bitmap bm_%s;\n", id); + } fclose(fh); } else { fprintf(f, @@ -492,6 +499,10 @@ void generate_c_source(char *id, char* header_dir, int width, int height, id, height, id, width); } + if (create_bm) { + fprintf(f, "#include \"%s\"\n", header_name); + } + if (t_depth <= 8) fprintf(f, "const unsigned char %s[] = {\n", id); else @@ -511,7 +522,20 @@ void generate_c_source(char *id, char* header_dir, int width, int height, fprintf(f, "\n"); } - fprintf(f, "\n};\n"); + fprintf(f, "\n};\n\n"); + + if (create_bm) { + char format_line[] = " .format = FORMAT_NATIVE, \n"; + fprintf(f, "const struct bitmap bm_%s = { \n" + " .width = BMPWIDTH_%s, \n" + " .height = BMPHEIGHT_%s, \n" + "%s" + " .data = (unsigned char*)%s,\n" + "};\n", + id, id, id, + t_mono ? "" : format_line, + id); + } } void generate_raw_file(const unsigned short *t_bitmap, @@ -573,6 +597,7 @@ void print_usage(void) "\t-i <id> Bitmap name (default is filename without extension)\n" "\t-h <dir> Create header file in <dir>/<id>.h\n" "\t-a Show ascii picture of bitmap\n" + "\t-b Create bitmap struct along with pixel array\n" "\t-r Generate RAW file (little-endian)\n" "\t-f <n> Generate destination format n, default = 0\n" "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" @@ -601,6 +626,7 @@ int main(int argc, char **argv) int width, height; int t_width, t_height, t_depth; bool raw = false; + bool create_bm = false; for (i = 1;i < argc;i++) @@ -647,6 +673,10 @@ int main(int argc, char **argv) ascii = true; break; + case 'b': + create_bm = true; + break; + case 'r': /* Raw File */ raw = true; break; @@ -724,7 +754,8 @@ int main(int argc, char **argv) generate_raw_file(t_bitmap, t_width, t_height, t_depth); else generate_c_source(id, header_dir, width, height, t_bitmap, - t_width, t_height, t_depth); + t_width, t_height, t_depth, + format <= 1, create_bm); } return 0; |