1
0
Fork 0
forked from len0rd/rockbox

Some changes to image code, thanks to Daniel.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6874 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomas Salfischberger 2005-06-26 15:42:34 +00:00
parent 37aaa13a3e
commit 9bfea3e746

View file

@ -758,9 +758,9 @@ static void format_display(char* buf,
int n; int n;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int ret; int ret;
const char *pos, *posn; char *pos, *posn;
char imgtmp[32];
char imgname[MAX_PATH]; char imgname[MAX_PATH];
char *ptr;
#endif #endif
*subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER; *subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER;
@ -803,47 +803,55 @@ static void format_display(char* buf,
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* get image number */ /* get image number */
pos = strchr(fmt, '|'); /* get the first '|' */ pos = strchr(fmt, '|'); /* get the first '|' */
if ((pos - fmt) < 32) { ptr = (char *)fmt+1;
strncpy(imgtmp, fmt+1, pos - fmt - 1); if (pos && ((pos - ptr) < (int)sizeof(temp_buf))) {
imgtmp[pos - fmt - 1] = 0; memcpy(temp_buf, ptr, pos - ptr);
n = atoi(imgtmp); temp_buf[pos - ptr] = 0;
n = atoi(temp_buf);
ptr = pos+1;
/* check image number, and load state. */ /* check image number, and load state. */
if ((n < MAX_IMAGES) && (!img[n].loaded)) { if ((n < MAX_IMAGES) && (!img[n].loaded)) {
/* Get filename */ /* Get filename */
pos = strchr(fmt+3, '|'); /* get the second '|' */ pos = strchr(ptr, '|'); /* get the second '|' */
if ((pos - fmt) < 32) { if ((pos - ptr) < (int)sizeof(temp_buf)) {
strncpy(imgtmp, fmt+3, pos - fmt - 3); /* get the filename */ memcpy(temp_buf, ptr, pos - ptr); /* get the filename */
imgtmp[pos - fmt - 3] = 0; temp_buf[pos - ptr] = 0;
} else { snprintf(imgname, MAX_PATH, "/.rockbox/%s", temp_buf);
/* hm.. filename is to long... */ }
*imgtmp = 0; else {
/* filename too long! */
imgname[0]=0;
} }
snprintf(imgname, MAX_PATH, "/.rockbox/%s", imgtmp);
/* Get X-position */ /* Get X-position */
posn = strchr(pos+1, '|'); /* get the 3th '|' */ ptr=pos+1;
if ((posn - fmt) < 32) { posn = strchr(ptr, '|'); /* get the 3th '|' */
strncpy(imgtmp, pos+1, posn - pos - 1); if ((posn - ptr) < (int)sizeof(temp_buf)) {
imgtmp[posn - pos - 1] = 0; memcpy(temp_buf, ptr, posn - ptr);
img[n].x = atoi(imgtmp); temp_buf[posn - ptr] = 0;
} else { img[n].x = atoi(temp_buf);
img[n].x = 0;
} }
else
/* weird syntax, get out */
break;
/* Get Y-position */ /* Get Y-position */
pos = posn; pos = posn;
posn = strchr(pos+1, '|'); /* get the 4th '|' */ ptr = posn+1;
if ((posn - fmt) < 32) { posn = strchr(ptr, '|'); /* get the 4th '|' */
strncpy(imgtmp, pos+1, posn - pos - 1); if ((posn - ptr) < (int)sizeof(temp_buf)) {
imgtmp[posn - pos - 1] = 0; memcpy(temp_buf, ptr, posn - ptr);
img[n].y = atoi(imgtmp); temp_buf[posn - ptr] = 0;
} else { img[n].y = atoi(temp_buf);
img[n].y = 0;
} }
else
/* weird syntax, get out */
break;
/* and load the image */ /* and load the image */
ret = read_bmp_file(imgname, &img[n].w, &img[n].h, img_buf_ptr, img_buf_free); ret = read_bmp_file(imgname, &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;