diff options
-rw-r--r-- | apps/gui/gwps.h | 7 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 53 |
2 files changed, 29 insertions, 31 deletions
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index 26a800cbbd..609e2af91f 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -69,6 +69,13 @@ struct align_pos { | |||
69 | #ifdef HAVE_LCD_BITMAP | 69 | #ifdef HAVE_LCD_BITMAP |
70 | 70 | ||
71 | #define MAX_IMAGES (26*2) /* a-z and A-Z */ | 71 | #define MAX_IMAGES (26*2) /* a-z and A-Z */ |
72 | |||
73 | #if LCD_DEPTH > 1 | ||
74 | #define MAX_BITMAPS MAX_IMAGES+2 /* WPS images + pbar bitmap + backdrop */ | ||
75 | #else | ||
76 | #define MAX_BITMAPS MAX_IMAGES+1 /* WPS images + pbar bitmap */ | ||
77 | #endif | ||
78 | |||
72 | #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ | 79 | #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ |
73 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) | 80 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) |
74 | 81 | ||
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index d363d6d8cb..5be93c6d91 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -65,11 +65,7 @@ static int line; | |||
65 | 65 | ||
66 | #ifdef HAVE_LCD_BITMAP | 66 | #ifdef HAVE_LCD_BITMAP |
67 | /* pointers to the bitmap filenames in the WPS source */ | 67 | /* pointers to the bitmap filenames in the WPS source */ |
68 | static const char *bmp_names[MAX_IMAGES]; | 68 | static const char *bmp_names[MAX_BITMAPS]; |
69 | static const char *pb_bmp_name; | ||
70 | #if LCD_DEPTH > 1 | ||
71 | static const char *backdrop_bmp_name; | ||
72 | #endif | ||
73 | #endif | 69 | #endif |
74 | 70 | ||
75 | #ifdef DEBUG | 71 | #ifdef DEBUG |
@@ -472,13 +468,13 @@ static int parse_image_special(const char *wps_bufptr, | |||
472 | if (token->type == WPS_TOKEN_IMAGE_PROGRESS_BAR) | 468 | if (token->type == WPS_TOKEN_IMAGE_PROGRESS_BAR) |
473 | { | 469 | { |
474 | /* format: %P|filename.bmp| */ | 470 | /* format: %P|filename.bmp| */ |
475 | pb_bmp_name = wps_bufptr + 1; | 471 | bmp_names[MAX_IMAGES] = wps_bufptr + 1; |
476 | } | 472 | } |
477 | #if LCD_DEPTH > 1 | 473 | #if LCD_DEPTH > 1 |
478 | else if (token->type == WPS_TOKEN_IMAGE_BACKDROP) | 474 | else if (token->type == WPS_TOKEN_IMAGE_BACKDROP) |
479 | { | 475 | { |
480 | /* format: %X|filename.bmp| */ | 476 | /* format: %X|filename.bmp| */ |
481 | backdrop_bmp_name = wps_bufptr + 1; | 477 | bmp_names[MAX_IMAGES + 1] = wps_bufptr + 1; |
482 | } | 478 | } |
483 | #endif | 479 | #endif |
484 | 480 | ||
@@ -912,54 +908,49 @@ static void wps_reset(struct wps_data *data) | |||
912 | static void clear_bmp_names(void) | 908 | static void clear_bmp_names(void) |
913 | { | 909 | { |
914 | int n; | 910 | int n; |
915 | for (n = 0; n < MAX_IMAGES; n++) | 911 | for (n = 0; n < MAX_BITMAPS; n++) |
916 | { | 912 | { |
917 | bmp_names[n] = NULL; | 913 | bmp_names[n] = NULL; |
918 | } | 914 | } |
919 | pb_bmp_name = NULL; | ||
920 | #if LCD_DEPTH > 1 | ||
921 | backdrop_bmp_name = NULL; | ||
922 | #endif | ||
923 | } | 915 | } |
924 | 916 | ||
925 | static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | 917 | static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) |
926 | { | 918 | { |
927 | char img_path[MAX_PATH]; | 919 | char img_path[MAX_PATH]; |
920 | struct bitmap *bitmap; | ||
921 | bool *loaded; | ||
928 | 922 | ||
929 | int n; | 923 | int n; |
930 | for (n = 0; n < MAX_IMAGES; n++) | 924 | for (n = 0; n < MAX_BITMAPS - 1; n++) |
931 | { | 925 | { |
932 | if (bmp_names[n]) | 926 | if (bmp_names[n]) |
933 | { | 927 | { |
934 | get_image_filename(bmp_names[n], bmpdir, | 928 | get_image_filename(bmp_names[n], bmpdir, |
935 | img_path, sizeof(img_path)); | 929 | img_path, sizeof(img_path)); |
936 | 930 | ||
931 | if (n == MAX_IMAGES) { | ||
932 | /* progressbar bitmap */ | ||
933 | bitmap = &wps_data->progressbar.bm; | ||
934 | loaded = &wps_data->progressbar.have_bitmap_pb; | ||
935 | } else { | ||
936 | /* regular bitmap */ | ||
937 | bitmap = &wps_data->img[n].bm; | ||
938 | loaded = &wps_data->img[n].loaded; | ||
939 | } | ||
940 | |||
937 | /* load the image */ | 941 | /* load the image */ |
938 | wps_data->img[n].bm.data = wps_data->img_buf_ptr; | 942 | bitmap->data = wps_data->img_buf_ptr; |
939 | if (load_bitmap(wps_data, img_path, &wps_data->img[n].bm)) | 943 | if (load_bitmap(wps_data, img_path, bitmap)) |
940 | { | 944 | { |
941 | wps_data->img[n].loaded = true; | 945 | *loaded = true; |
942 | } | 946 | } |
943 | } | 947 | } |
944 | } | 948 | } |
945 | 949 | ||
946 | if (pb_bmp_name) | ||
947 | { | ||
948 | get_image_filename(pb_bmp_name, bmpdir, img_path, sizeof(img_path)); | ||
949 | |||
950 | /* load the image */ | ||
951 | wps_data->progressbar.bm.data = wps_data->img_buf_ptr; | ||
952 | if (load_bitmap(wps_data, img_path, &wps_data->progressbar.bm) | ||
953 | && wps_data->progressbar.bm.width <= LCD_WIDTH) | ||
954 | { | ||
955 | wps_data->progressbar.have_bitmap_pb = true; | ||
956 | } | ||
957 | } | ||
958 | |||
959 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) | 950 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) |
960 | if (backdrop_bmp_name) | 951 | if (bmp_names[MAX_IMAGES + 1]) |
961 | { | 952 | { |
962 | get_image_filename(backdrop_bmp_name, bmpdir, | 953 | get_image_filename(bmp_names[MAX_IMAGES + 1], bmpdir, |
963 | img_path, sizeof(img_path)); | 954 | img_path, sizeof(img_path)); |
964 | #ifdef HAVE_REMOTE_LCD | 955 | #ifdef HAVE_REMOTE_LCD |
965 | if (wps_data->remote_wps) | 956 | if (wps_data->remote_wps) |