From d9e5b67b71cf246c11da8a9083af21752ac7bd15 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 2 Feb 2006 20:42:56 +0000 Subject: Patch #1421422 - Backdrop image patch started by Linus, finished by me. Adds ability to set backdrop images for file browser and menus (store full-screen bitmaps in /.rockbox/backdrops/) and also the ability to set a full-screen background image in a WPS using the %X|filename.bmp| WPS tag. Currently only implemented for targets with colour LCDs. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8536 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'apps/gui/gwps-common.c') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index ca839a9bfa..09c271b904 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -28,6 +28,7 @@ #include "power.h" #include "powermgmt.h" #include "sound.h" +#include "debug.h" #ifdef HAVE_LCD_CHARCELLS #include "hwcompat.h" #endif @@ -36,10 +37,11 @@ #include "backlight.h" #include "lang.h" #include "misc.h" - +#include "backdrop.h" #include "splash.h" #include "scrollbar.h" #include "led.h" +#include "lcd.h" #ifdef HAVE_LCD_BITMAP #include "peakmeter.h" /* Image stuff */ @@ -57,6 +59,10 @@ static void draw_player_fullbar(struct gui_wps *gwps, /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 +#ifdef HAVE_LCD_COLOR +extern bool wps_has_backdrop; +#endif + /* Skip leading UTF-8 BOM, if present. */ static char* skip_utf8_bom(char* buf) { @@ -88,6 +94,7 @@ static int get_image_id(int c) /* * parse the given buffer for following static tags: * %x - load image for always display + * %X - load backdrop image * %xl - preload image * %we - enable statusbar on wps regardless of the global setting * %wd - disable statusbar on wps regardless of the global setting @@ -133,7 +140,54 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf, return true; } break; - + +#ifdef HAVE_LCD_COLOR + case 'X': + /* Backdrop image - must be the same size as the LCD */ + { + int ret = 0; + struct bitmap bm; + char *ptr = buf+2; + char *pos = NULL; + char imgname[MAX_PATH]; + + /* format: %X|filename.bmp| */ + { + /* get filename */ + pos = strchr(ptr, '|'); + if ((pos - ptr) < + (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2) + { + memcpy(imgname, bmpdir, bmpdirlen); + imgname[bmpdirlen] = '/'; + memcpy(&imgname[bmpdirlen+1], + ptr, pos - ptr); + imgname[bmpdirlen+1+pos-ptr] = 0; + } + else + /* filename too long */ + imgname[0] = 0; + + ptr = pos+1; + + /* load the image */ + bm.data=(char*)&wps_backdrop[0][0]; + ret = read_bmp_file(imgname, &bm, + sizeof(wps_backdrop), FORMAT_NATIVE); + + if ((ret > 0) && (bm.width == LCD_WIDTH) + && (bm.height == LCD_HEIGHT)) { + wps_has_backdrop=true; + return true; + } else { + return false; + } + } + } + + break; +#endif + case 'x': /* Preload images so the %xd# tag can display it */ { -- cgit v1.2.3