forked from len0rd/rockbox
New WPS image code, introducing a new format :)
%xn|filename|x|y| for example: %x0|test.bmp|10|23| the example will load /.rockbox/test.bmp as image 0 on position 10,23 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6810 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
714358a42c
commit
4fd457a2bf
1 changed files with 60 additions and 19 deletions
|
|
@ -745,9 +745,12 @@ static void format_display(char* buf,
|
||||||
unsigned char tag_length;
|
unsigned char tag_length;
|
||||||
|
|
||||||
/* needed for images (ifdef is to kill a warning on player)*/
|
/* needed for images (ifdef is to kill a warning on player)*/
|
||||||
|
int n;
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
int n, ret;
|
int ret;
|
||||||
|
const char *pos, *posn;
|
||||||
char imgtmp[32];
|
char imgtmp[32];
|
||||||
|
char imgname[MAX_PATH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER;
|
*subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER;
|
||||||
|
|
@ -786,19 +789,51 @@ static void format_display(char* buf,
|
||||||
++fmt;
|
++fmt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x': /* image support */
|
case 'x': /* image support (format: %xn|filename|x|y|) */
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
strncpy(imgtmp, fmt+1, 1);
|
/* get image number */
|
||||||
n = atoi(imgtmp); /* get image number */
|
pos = strchr(fmt, '|'); /* get the first '|' */
|
||||||
if (!img[n].loaded) {
|
if ((pos - fmt) < 32) {
|
||||||
/* image not loaded, get extra info. */
|
strncpy(imgtmp, fmt+1, pos - fmt - 1);
|
||||||
strncpy(imgtmp, fmt+2, 3);
|
imgtmp[pos - fmt - 1] = 0;
|
||||||
|
n = atoi(imgtmp);
|
||||||
|
|
||||||
|
/* check image number, and load state. */
|
||||||
|
if ((n < MAX_IMAGES) && (!img[n].loaded)) {
|
||||||
|
/* Get filename */
|
||||||
|
pos = strchr(fmt+3, '|'); /* get the second '|' */
|
||||||
|
if ((pos - fmt) < 32) {
|
||||||
|
strncpy(imgtmp, fmt+3, pos - fmt - 3); /* get the filename */
|
||||||
|
imgtmp[pos - fmt - 3] = 0;
|
||||||
|
} else {
|
||||||
|
/* hm.. filename is to long... */
|
||||||
|
*imgtmp = 0;
|
||||||
|
}
|
||||||
|
snprintf(imgname, MAX_PATH, "/.rockbox/%s", imgtmp);
|
||||||
|
|
||||||
|
/* Get X-position */
|
||||||
|
posn = strchr(pos+1, '|'); /* get the 3th '|' */
|
||||||
|
if ((posn - fmt) < 32) {
|
||||||
|
strncpy(imgtmp, pos+1, posn - pos - 1);
|
||||||
|
imgtmp[posn - pos - 1] = 0;
|
||||||
img[n].x = atoi(imgtmp);
|
img[n].x = atoi(imgtmp);
|
||||||
strncpy(imgtmp, fmt+5, 3);
|
} else {
|
||||||
|
img[n].x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get Y-position */
|
||||||
|
pos = posn;
|
||||||
|
posn = strchr(pos+1, '|'); /* get the 4th '|' */
|
||||||
|
if ((posn - fmt) < 32) {
|
||||||
|
strncpy(imgtmp, pos+1, posn - pos - 1);
|
||||||
|
imgtmp[posn - pos - 1] = 0;
|
||||||
img[n].y = atoi(imgtmp);
|
img[n].y = atoi(imgtmp);
|
||||||
|
} else {
|
||||||
|
img[n].y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* and load the image */
|
/* and load the image */
|
||||||
snprintf(imgtmp, 32, "/.rockbox/img_%d.bmp", n);
|
ret = read_bmp_file(imgname, &img[n].w, &img[n].h, img_buf_ptr, img_buf_free);
|
||||||
ret = read_bmp_file(imgtmp, &img[n].w, &img[n].h, img_buf_ptr, img_buf_free);
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
img[n].ptr = img_buf_ptr;
|
img[n].ptr = img_buf_ptr;
|
||||||
img_buf_ptr += ret;
|
img_buf_ptr += ret;
|
||||||
|
|
@ -806,8 +841,14 @@ static void format_display(char* buf,
|
||||||
}
|
}
|
||||||
img[n].loaded = true;
|
img[n].loaded = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
fmt += 8;
|
/* skip the tag */
|
||||||
|
/* WARNING! This will crash if there's a syntax error in the wps file */
|
||||||
|
for (n = 0; n < 4; n++) {
|
||||||
|
fmt = strchr(fmt+1, '|'); /* get the next '|' */
|
||||||
|
}
|
||||||
|
fmt++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue