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
This commit is contained in:
Thomas Martitz 2011-11-13 15:37:16 +00:00
parent 61f61c9773
commit 9a70c42241
7 changed files with 61 additions and 42 deletions

View file

@ -36,16 +36,16 @@ $(BMPHFILES): $(BMPOBJ)
# pattern rules to create .c files from .bmp, one for each subdir: # pattern rules to create .c files from .bmp, one for each subdir:
$(BUILDDIR)/apps/bitmaps/mono/%.c: $(ROOTDIR)/apps/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/bitmaps/mono/%.c: $(ROOTDIR)/apps/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -h $(BMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -b -h $(BMPINCDIR) $< > $@
$(BUILDDIR)/apps/bitmaps/native/%.c: $(ROOTDIR)/apps/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/bitmaps/native/%.c: $(ROOTDIR)/apps/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -h $(BMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -b -h $(BMPINCDIR) $< > $@
$(BUILDDIR)/apps/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -h $(BMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -b -h $(BMPINCDIR) $< > $@
$(BUILDDIR)/apps/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(BMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(BMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -h $(BMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -b -h $(BMPINCDIR) $< > $@

View file

@ -44,19 +44,11 @@
/* We dont actually do anything with these pointers, /* We dont actually do anything with these pointers,
but they need to be grouped like this to save code but they need to be grouped like this to save code
so storing them as void* is ok. (stops compile warning) */ so storing them as void* is ok. (stops compile warning) */
static const struct bitmap inbuilt_iconset[NB_SCREENS] = static const struct bitmap *inbuilt_iconset[NB_SCREENS] =
{ {
{ &bm_default_icons,
.width = BMPWIDTH_default_icons,
.height = BMPHEIGHT_default_icons,
.data = (unsigned char*)default_icons,
},
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
{ &bm_remote_default_icons,
.width = BMPWIDTH_remote_default_icons,
.height = BMPHEIGHT_remote_default_icons,
.data = (unsigned char*)remote_default_icons,
},
#endif #endif
}; };
@ -74,11 +66,11 @@ struct iconset {
} iconsets[Iconset_Count][NB_SCREENS]; } iconsets[Iconset_Count][NB_SCREENS];
#define ICON_HEIGHT(screen) (!iconsets[Iconset_user][screen].loaded ? \ #define ICON_HEIGHT(screen) (!iconsets[Iconset_user][screen].loaded ? \
inbuilt_iconset[screen] : iconsets[Iconset_user][screen].bmp).height \ (*(inbuilt_iconset[screen])) : iconsets[Iconset_user][screen].bmp).height \
/ Icon_Last_Themeable / Icon_Last_Themeable
#define ICON_WIDTH(screen) (!iconsets[Iconset_user][screen].loaded ? \ #define ICON_WIDTH(screen) (!iconsets[Iconset_user][screen].loaded ? \
inbuilt_iconset[screen] : iconsets[Iconset_user][screen].bmp).width (*(inbuilt_iconset[screen])) : iconsets[Iconset_user][screen].bmp).width
/* x,y in letters, not pixles */ /* x,y in letters, not pixles */
void screen_put_icon(struct screen * display, void screen_put_icon(struct screen * display,
@ -140,7 +132,7 @@ void screen_put_iconxy(struct screen * display,
} }
else else
{ {
iconset = &inbuilt_iconset[screen]; iconset = inbuilt_iconset[screen];
} }
/* add some left padding to the icons if they are on the edge */ /* add some left padding to the icons if they are on the edge */
if (xpos == 0) if (xpos == 0)

View file

@ -184,6 +184,12 @@ static void usb_screen_fix_viewports(struct screen *screen,
static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
{ {
static const struct bitmap* logos[NB_SCREENS] = {
&bm_usblogo,
#ifdef HAVE_RE
&bm_remote_usblogo,
#endif
};
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
struct screen *screen = &screens[i]; struct screen *screen = &screens[i];
@ -200,17 +206,9 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
screen->set_viewport(logo); screen->set_viewport(logo);
#ifdef HAVE_REMOTE_LCD screen->bmp(logos[i], 0, 0);
if (i == SCREEN_REMOTE) if (i == SCREEN_MAIN)
{ {
screen->bitmap(remote_usblogo, 0, 0, logo->width,
logo->height);
}
else
#endif
{
screen->transparent_bitmap(usblogo, 0, 0, logo->width,
logo->height);
#ifdef USB_ENABLE_HID #ifdef USB_ENABLE_HID
if (usb_hid) if (usb_hid)
{ {

View file

@ -691,11 +691,9 @@ int show_logo( void )
lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); lcd_getstringsize((unsigned char *)"A", &font_w, &font_h);
lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
0, (unsigned char *)version); 0, (unsigned char *)version);
lcd_bitmap(rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16, lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16);
BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
#else #else
lcd_bitmap(rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10, lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10);
BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); lcd_getstringsize((unsigned char *)"A", &font_w, &font_h);
lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),

View file

@ -43,18 +43,18 @@ $(PLUGINBITMAPLIB): $(PLUGIN_BITMAPS)
# pattern rules to create .c files from .bmp, one for each subdir: # pattern rules to create .c files from .bmp, one for each subdir:
$(BUILDDIR)/apps/plugins/bitmaps/mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/plugins/bitmaps/mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/mono/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -h $(PBMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_MONO) -b -h $(PBMPINCDIR) $< > $@
$(BUILDDIR)/apps/plugins/bitmaps/native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/plugins/bitmaps/native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/native/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -h $(PBMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_NATIVE) -b -h $(PBMPINCDIR) $< > $@
$(BUILDDIR)/apps/plugins/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/plugins/bitmaps/remote_mono/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_mono/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -h $(PBMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTEMONO) -b -h $(PBMPINCDIR) $< > $@
$(BUILDDIR)/apps/plugins/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb $(BUILDDIR)/apps/plugins/bitmaps/remote_native/%.c: $(ROOTDIR)/apps/plugins/bitmaps/remote_native/%.bmp $(TOOLSDIR)/bmp2rb
$(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR) $(SILENT)mkdir -p $(dir $@) $(PBMPINCDIR)
$(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -h $(PBMPINCDIR) $< > $@ $(call PRINTS,BMP2RB $(<F))$(BMP2RB_REMOTENATIVE) -b -h $(PBMPINCDIR) $< > $@
endif endif

View file

@ -46,9 +46,9 @@ void show_logo( void )
/* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48 /* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48
are blue, so we reverse the usual positioning */ are blue, so we reverse the usual positioning */
lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION); lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION);
lcd_bitmap(rockboxlogo, 0, 16, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); lcd_bmp(&bm_rockboxlogo, 0, 16);
#else #else
lcd_bitmap(rockboxlogo, 0, 10, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); lcd_bmp(&bm_rockboxlogo, 0, 10);
lcd_putsxy(TEXT_XPOS, LCD_HEIGHT-SYSFONT_HEIGHT, BOOT_VERSION); lcd_putsxy(TEXT_XPOS, LCD_HEIGHT-SYSFONT_HEIGHT, BOOT_VERSION);
#endif #endif

View file

@ -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, void generate_c_source(char *id, char* header_dir, int width, int height,
const unsigned short *t_bitmap, int t_width, 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 *f;
FILE *fh; FILE *fh;
int i, a; int i, a;
char header_name[1024]; char header_name[1024];
bool have_header = header_dir && header_dir[0];
create_bm = have_header && create_bm;
if (!id || !id[0]) if (!id || !id[0])
id = "bitmap"; id = "bitmap";
f = stdout; f = stdout;
if (header_dir && header_dir[0]) if (have_header)
{ {
snprintf(header_name,sizeof(header_name),"%s/%s.h",header_dir,id); snprintf(header_name,sizeof(header_name),"%s/%s.h",header_dir,id);
fh = fopen(header_name,"w+"); fh = fopen(header_name,"w+");
@ -484,6 +486,11 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
else else
fprintf(fh, "extern const unsigned short %s[];\n", id); 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); fclose(fh);
} else { } else {
fprintf(f, fprintf(f,
@ -492,6 +499,10 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
id, height, id, width); id, height, id, width);
} }
if (create_bm) {
fprintf(f, "#include \"%s\"\n", header_name);
}
if (t_depth <= 8) if (t_depth <= 8)
fprintf(f, "const unsigned char %s[] = {\n", id); fprintf(f, "const unsigned char %s[] = {\n", id);
else else
@ -511,7 +522,20 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
fprintf(f, "\n"); 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, 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-i <id> Bitmap name (default is filename without extension)\n"
"\t-h <dir> Create header file in <dir>/<id>.h\n" "\t-h <dir> Create header file in <dir>/<id>.h\n"
"\t-a Show ascii picture of bitmap\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-r Generate RAW file (little-endian)\n"
"\t-f <n> Generate destination format n, default = 0\n" "\t-f <n> Generate destination format n, default = 0\n"
"\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n"
@ -601,6 +626,7 @@ int main(int argc, char **argv)
int width, height; int width, height;
int t_width, t_height, t_depth; int t_width, t_height, t_depth;
bool raw = false; bool raw = false;
bool create_bm = false;
for (i = 1;i < argc;i++) for (i = 1;i < argc;i++)
@ -647,6 +673,10 @@ int main(int argc, char **argv)
ascii = true; ascii = true;
break; break;
case 'b':
create_bm = true;
break;
case 'r': /* Raw File */ case 'r': /* Raw File */
raw = true; raw = true;
break; break;
@ -724,7 +754,8 @@ int main(int argc, char **argv)
generate_raw_file(t_bitmap, t_width, t_height, t_depth); generate_raw_file(t_bitmap, t_width, t_height, t_depth);
else else
generate_c_source(id, header_dir, width, height, t_bitmap, 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; return 0;