summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-11-13 15:37:16 +0000
committerThomas Martitz <kugel@rockbox.org>2011-11-13 15:37:16 +0000
commit9a70c42241c70e57bbe739f45d254c67bacc83e7 (patch)
tree2387eebfd2f3ad83c5e4e69d6d39fd37f234d928
parent61f61c97738a3f0e279b7c31f9096a5aaa977291 (diff)
downloadrockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.tar.gz
rockbox-9a70c42241c70e57bbe739f45d254c67bacc83e7.zip
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
-rw-r--r--apps/bitmaps/bitmaps.make8
-rw-r--r--apps/gui/icon.c20
-rw-r--r--apps/gui/usb_screen.c18
-rw-r--r--apps/misc.c6
-rw-r--r--apps/plugins/bitmaps/pluginbitmaps.make8
-rw-r--r--bootloader/show_logo.c4
-rw-r--r--tools/bmp2rb.c39
7 files changed, 61 insertions, 42 deletions
diff --git a/apps/bitmaps/bitmaps.make b/apps/bitmaps/bitmaps.make
index 945ca82ce0..159c31b64f 100644
--- a/apps/bitmaps/bitmaps.make
+++ b/apps/bitmaps/bitmaps.make
@@ -36,16 +36,16 @@ $(BMPHFILES): $(BMPOBJ)
36# pattern rules to create .c files from .bmp, one for each subdir: 36# pattern rules to create .c files from .bmp, one for each subdir:
37$(BUILDDIR)/apps/bitmaps/mono/%.c: $(ROOTDIR)/apps/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb 37$(BUILDDIR)/apps/bitmaps/mono/%.c: $(ROOTDIR)/apps/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb
38 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) 38 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
39 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -h $(BMPINCDIR) $< > $@ 39 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -b -h $(BMPINCDIR) $< > $@
40 40
41$(BUILDDIR)/apps/bitmaps/native/%.c: $(ROOTDIR)/apps/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb 41$(BUILDDIR)/apps/bitmaps/native/%.c: $(ROOTDIR)/apps/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb
42 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) 42 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
43 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -h $(BMPINCDIR) $< > $@ 43 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -b -h $(BMPINCDIR) $< > $@
44 44
45$(BUILDDIR)/apps/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb 45$(BUILDDIR)/apps/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb
46 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) 46 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
47 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -h $(BMPINCDIR) $< > $@ 47 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -b -h $(BMPINCDIR) $< > $@
48 48
49$(BUILDDIR)/apps/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb 49$(BUILDDIR)/apps/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb
50 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) 50 $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
51 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -h $(BMPINCDIR) $< > $@ 51 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -b -h $(BMPINCDIR) $< > $@
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 5684ff057c..a9075b1b0f 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -44,19 +44,11 @@
44/* We dont actually do anything with these pointers, 44/* We dont actually do anything with these pointers,
45 but they need to be grouped like this to save code 45 but they need to be grouped like this to save code
46 so storing them as void* is ok. (stops compile warning) */ 46 so storing them as void* is ok. (stops compile warning) */
47static const struct bitmap inbuilt_iconset[NB_SCREENS] = 47static const struct bitmap *inbuilt_iconset[NB_SCREENS] =
48{ 48{
49 { 49 &bm_default_icons,
50 .width = BMPWIDTH_default_icons,
51 .height = BMPHEIGHT_default_icons,
52 .data = (unsigned char*)default_icons,
53 },
54#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) 50#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
55 { 51 &bm_remote_default_icons,
56 .width = BMPWIDTH_remote_default_icons,
57 .height = BMPHEIGHT_remote_default_icons,
58 .data = (unsigned char*)remote_default_icons,
59 },
60#endif 52#endif
61}; 53};
62 54
@@ -74,11 +66,11 @@ struct iconset {
74} iconsets[Iconset_Count][NB_SCREENS]; 66} iconsets[Iconset_Count][NB_SCREENS];
75 67
76#define ICON_HEIGHT(screen) (!iconsets[Iconset_user][screen].loaded ? \ 68#define ICON_HEIGHT(screen) (!iconsets[Iconset_user][screen].loaded ? \
77 inbuilt_iconset[screen] : iconsets[Iconset_user][screen].bmp).height \ 69 (*(inbuilt_iconset[screen])) : iconsets[Iconset_user][screen].bmp).height \
78 / Icon_Last_Themeable 70 / Icon_Last_Themeable
79 71
80#define ICON_WIDTH(screen) (!iconsets[Iconset_user][screen].loaded ? \ 72#define ICON_WIDTH(screen) (!iconsets[Iconset_user][screen].loaded ? \
81 inbuilt_iconset[screen] : iconsets[Iconset_user][screen].bmp).width 73 (*(inbuilt_iconset[screen])) : iconsets[Iconset_user][screen].bmp).width
82 74
83/* x,y in letters, not pixles */ 75/* x,y in letters, not pixles */
84void screen_put_icon(struct screen * display, 76void screen_put_icon(struct screen * display,
@@ -140,7 +132,7 @@ void screen_put_iconxy(struct screen * display,
140 } 132 }
141 else 133 else
142 { 134 {
143 iconset = &inbuilt_iconset[screen]; 135 iconset = inbuilt_iconset[screen];
144 } 136 }
145 /* add some left padding to the icons if they are on the edge */ 137 /* add some left padding to the icons if they are on the edge */
146 if (xpos == 0) 138 if (xpos == 0)
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index 2b7d47209b..002f4557bb 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -184,6 +184,12 @@ static void usb_screen_fix_viewports(struct screen *screen,
184 184
185static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) 185static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
186{ 186{
187 static const struct bitmap* logos[NB_SCREENS] = {
188 &bm_usblogo,
189#ifdef HAVE_RE
190 &bm_remote_usblogo,
191#endif
192 };
187 FOR_NB_SCREENS(i) 193 FOR_NB_SCREENS(i)
188 { 194 {
189 struct screen *screen = &screens[i]; 195 struct screen *screen = &screens[i];
@@ -200,17 +206,9 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
200 206
201#ifdef HAVE_LCD_BITMAP 207#ifdef HAVE_LCD_BITMAP
202 screen->set_viewport(logo); 208 screen->set_viewport(logo);
203#ifdef HAVE_REMOTE_LCD 209 screen->bmp(logos[i], 0, 0);
204 if (i == SCREEN_REMOTE) 210 if (i == SCREEN_MAIN)
205 {
206 screen->bitmap(remote_usblogo, 0, 0, logo->width,
207 logo->height);
208 }
209 else
210#endif
211 { 211 {
212 screen->transparent_bitmap(usblogo, 0, 0, logo->width,
213 logo->height);
214#ifdef USB_ENABLE_HID 212#ifdef USB_ENABLE_HID
215 if (usb_hid) 213 if (usb_hid)
216 { 214 {
diff --git a/apps/misc.c b/apps/misc.c
index 72457cdbe7..271e4e1fd1 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -691,11 +691,9 @@ int show_logo( void )
691 lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); 691 lcd_getstringsize((unsigned char *)"A", &font_w, &font_h);
692 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), 692 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
693 0, (unsigned char *)version); 693 0, (unsigned char *)version);
694 lcd_bitmap(rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16, 694 lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16);
695 BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
696#else 695#else
697 lcd_bitmap(rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10, 696 lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10);
698 BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
699 lcd_setfont(FONT_SYSFIXED); 697 lcd_setfont(FONT_SYSFIXED);
700 lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); 698 lcd_getstringsize((unsigned char *)"A", &font_w, &font_h);
701 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), 699 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
diff --git a/apps/plugins/bitmaps/pluginbitmaps.make b/apps/plugins/bitmaps/pluginbitmaps.make
index f9b4adb033..85536ed3bb 100644
--- a/apps/plugins/bitmaps/pluginbitmaps.make
+++ b/apps/plugins/bitmaps/pluginbitmaps.make
@@ -43,18 +43,18 @@ $(PLUGINBITMAPLIB): $(PLUGIN_BITMAPS)
43# pattern rules to create .c files from .bmp, one for each subdir: 43# pattern rules to create .c files from .bmp, one for each subdir:
44$(BUILDDIR)/apps/plugins/bitmaps/mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb 44$(BUILDDIR)/apps/plugins/bitmaps/mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb
45 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) 45 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
46 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -h $(PBMPINCDIR) $< > $@ 46 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -b -h $(PBMPINCDIR) $< > $@
47 47
48$(BUILDDIR)/apps/plugins/bitmaps/native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb 48$(BUILDDIR)/apps/plugins/bitmaps/native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb
49 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) 49 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
50 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -h $(PBMPINCDIR) $< > $@ 50 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -b -h $(PBMPINCDIR) $< > $@
51 51
52$(BUILDDIR)/apps/plugins/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb 52$(BUILDDIR)/apps/plugins/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb
53 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) 53 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
54 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -h $(PBMPINCDIR) $< > $@ 54 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -b -h $(PBMPINCDIR) $< > $@
55 55
56$(BUILDDIR)/apps/plugins/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb 56$(BUILDDIR)/apps/plugins/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb
57 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) 57 $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
58 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -h $(PBMPINCDIR) $< > $@ 58 $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -b -h $(PBMPINCDIR) $< > $@
59 59
60endif 60endif
diff --git a/bootloader/show_logo.c b/bootloader/show_logo.c
index 4b52e94084..60481367d5 100644
--- a/bootloader/show_logo.c
+++ b/bootloader/show_logo.c
@@ -46,9 +46,9 @@ void show_logo( void )
46 /* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48 46 /* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48
47 are blue, so we reverse the usual positioning */ 47 are blue, so we reverse the usual positioning */
48 lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION); 48 lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION);
49 lcd_bitmap(rockboxlogo, 0, 16, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); 49 lcd_bmp(&bm_rockboxlogo, 0, 16);
50#else 50#else
51 lcd_bitmap(rockboxlogo, 0, 10, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); 51 lcd_bmp(&bm_rockboxlogo, 0, 10);
52 lcd_putsxy(TEXT_XPOS, LCD_HEIGHT-SYSFONT_HEIGHT, BOOT_VERSION); 52 lcd_putsxy(TEXT_XPOS, LCD_HEIGHT-SYSFONT_HEIGHT, BOOT_VERSION);
53#endif 53#endif
54 54
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c
index f9f554a304..7fee1e6177 100644
--- a/tools/bmp2rb.c
+++ b/tools/bmp2rb.c
@@ -453,19 +453,21 @@ int transform_bitmap(const struct RGBQUAD *src, int width, int height,
453 453
454void generate_c_source(char *id, char* header_dir, int width, int height, 454void generate_c_source(char *id, char* header_dir, int width, int height,
455 const unsigned short *t_bitmap, int t_width, 455 const unsigned short *t_bitmap, int t_width,
456 int t_height, int t_depth) 456 int t_height, int t_depth, bool t_mono, bool create_bm)
457{ 457{
458 FILE *f; 458 FILE *f;
459 FILE *fh; 459 FILE *fh;
460 int i, a; 460 int i, a;
461 char header_name[1024]; 461 char header_name[1024];
462 bool have_header = header_dir && header_dir[0];
463 create_bm = have_header && create_bm;
462 464
463 if (!id || !id[0]) 465 if (!id || !id[0])
464 id = "bitmap"; 466 id = "bitmap";
465 467
466 f = stdout; 468 f = stdout;
467 469
468 if (header_dir && header_dir[0]) 470 if (have_header)
469 { 471 {
470 snprintf(header_name,sizeof(header_name),"%s/%s.h",header_dir,id); 472 snprintf(header_name,sizeof(header_name),"%s/%s.h",header_dir,id);
471 fh = fopen(header_name,"w+"); 473 fh = fopen(header_name,"w+");
@@ -484,6 +486,11 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
484 else 486 else
485 fprintf(fh, "extern const unsigned short %s[];\n", id); 487 fprintf(fh, "extern const unsigned short %s[];\n", id);
486 488
489 if (create_bm)
490 {
491 fprintf(f, "#include \"lcd.h\"\n");
492 fprintf(fh, "extern const struct bitmap bm_%s;\n", id);
493 }
487 fclose(fh); 494 fclose(fh);
488 } else { 495 } else {
489 fprintf(f, 496 fprintf(f,
@@ -492,6 +499,10 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
492 id, height, id, width); 499 id, height, id, width);
493 } 500 }
494 501
502 if (create_bm) {
503 fprintf(f, "#include \"%s\"\n", header_name);
504 }
505
495 if (t_depth <= 8) 506 if (t_depth <= 8)
496 fprintf(f, "const unsigned char %s[] = {\n", id); 507 fprintf(f, "const unsigned char %s[] = {\n", id);
497 else 508 else
@@ -511,7 +522,20 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
511 fprintf(f, "\n"); 522 fprintf(f, "\n");
512 } 523 }
513 524
514 fprintf(f, "\n};\n"); 525 fprintf(f, "\n};\n\n");
526
527 if (create_bm) {
528 char format_line[] = " .format = FORMAT_NATIVE, \n";
529 fprintf(f, "const struct bitmap bm_%s = { \n"
530 " .width = BMPWIDTH_%s, \n"
531 " .height = BMPHEIGHT_%s, \n"
532 "%s"
533 " .data = (unsigned char*)%s,\n"
534 "};\n",
535 id, id, id,
536 t_mono ? "" : format_line,
537 id);
538 }
515} 539}
516 540
517void generate_raw_file(const unsigned short *t_bitmap, 541void generate_raw_file(const unsigned short *t_bitmap,
@@ -573,6 +597,7 @@ void print_usage(void)
573 "\t-i <id> Bitmap name (default is filename without extension)\n" 597 "\t-i <id> Bitmap name (default is filename without extension)\n"
574 "\t-h <dir> Create header file in <dir>/<id>.h\n" 598 "\t-h <dir> Create header file in <dir>/<id>.h\n"
575 "\t-a Show ascii picture of bitmap\n" 599 "\t-a Show ascii picture of bitmap\n"
600 "\t-b Create bitmap struct along with pixel array\n"
576 "\t-r Generate RAW file (little-endian)\n" 601 "\t-r Generate RAW file (little-endian)\n"
577 "\t-f <n> Generate destination format n, default = 0\n" 602 "\t-f <n> Generate destination format n, default = 0\n"
578 "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" 603 "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n"
@@ -601,6 +626,7 @@ int main(int argc, char **argv)
601 int width, height; 626 int width, height;
602 int t_width, t_height, t_depth; 627 int t_width, t_height, t_depth;
603 bool raw = false; 628 bool raw = false;
629 bool create_bm = false;
604 630
605 631
606 for (i = 1;i < argc;i++) 632 for (i = 1;i < argc;i++)
@@ -647,6 +673,10 @@ int main(int argc, char **argv)
647 ascii = true; 673 ascii = true;
648 break; 674 break;
649 675
676 case 'b':
677 create_bm = true;
678 break;
679
650 case 'r': /* Raw File */ 680 case 'r': /* Raw File */
651 raw = true; 681 raw = true;
652 break; 682 break;
@@ -724,7 +754,8 @@ int main(int argc, char **argv)
724 generate_raw_file(t_bitmap, t_width, t_height, t_depth); 754 generate_raw_file(t_bitmap, t_width, t_height, t_depth);
725 else 755 else
726 generate_c_source(id, header_dir, width, height, t_bitmap, 756 generate_c_source(id, header_dir, width, height, t_bitmap,
727 t_width, t_height, t_depth); 757 t_width, t_height, t_depth,
758 format <= 1, create_bm);
728 } 759 }
729 760
730 return 0; 761 return 0;