diff options
Diffstat (limited to 'apps/plugins/imageviewer/imageviewer.c')
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.c | 98 |
1 files changed, 82 insertions, 16 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c index ba5f8fec16..77286bd37d 100644 --- a/apps/plugins/imageviewer/imageviewer.c +++ b/apps/plugins/imageviewer/imageviewer.c | |||
@@ -838,16 +838,12 @@ static void get_view(struct image_info *info, int *p_cx, int *p_cy) | |||
838 | } | 838 | } |
839 | 839 | ||
840 | /* load, decode, display the image */ | 840 | /* load, decode, display the image */ |
841 | static int load_and_show(char* filename, struct image_info *info) | 841 | static int load_and_show(char *filename, struct image_info *info, |
842 | int offset, int filesize, int status) | ||
842 | { | 843 | { |
843 | int status; | ||
844 | int cx, cy; | 844 | int cx, cy; |
845 | ssize_t remaining; | 845 | ssize_t remaining; |
846 | 846 | ||
847 | rb->lcd_clear_display(); | ||
848 | |||
849 | /* suppress warning while running slideshow */ | ||
850 | status = get_image_type(filename, iv_api.running_slideshow); | ||
851 | if (status == IMAGE_UNKNOWN) { | 847 | if (status == IMAGE_UNKNOWN) { |
852 | /* file isn't supported image file, skip this. */ | 848 | /* file isn't supported image file, skip this. */ |
853 | file_pt[curfile] = NULL; | 849 | file_pt[curfile] = NULL; |
@@ -855,6 +851,8 @@ static int load_and_show(char* filename, struct image_info *info) | |||
855 | } | 851 | } |
856 | 852 | ||
857 | reload_decoder: | 853 | reload_decoder: |
854 | rb->lcd_clear_display(); | ||
855 | |||
858 | if (image_type != status) /* type of image is changed, load decoder. */ | 856 | if (image_type != status) /* type of image is changed, load decoder. */ |
859 | { | 857 | { |
860 | struct loader_info loader_info = { | 858 | struct loader_info loader_info = { |
@@ -881,11 +879,10 @@ reload_decoder: | |||
881 | if (rb->button_get(false) == IMGVIEW_MENU) | 879 | if (rb->button_get(false) == IMGVIEW_MENU) |
882 | status = PLUGIN_ABORT; | 880 | status = PLUGIN_ABORT; |
883 | else | 881 | else |
884 | status = imgdec->load_image(filename, info, buf, &remaining); | 882 | status = imgdec->load_image(filename, info, buf, &remaining, offset, filesize); |
885 | 883 | ||
886 | if (status == PLUGIN_JPEG_PROGRESSIVE) | 884 | if (status == PLUGIN_JPEG_PROGRESSIVE) |
887 | { | 885 | { |
888 | rb->lcd_clear_display(); | ||
889 | status = IMAGE_JPEG_PROGRESSIVE; | 886 | status = IMAGE_JPEG_PROGRESSIVE; |
890 | goto reload_decoder; | 887 | goto reload_decoder; |
891 | } | 888 | } |
@@ -1035,6 +1032,47 @@ reload_decoder: | |||
1035 | return status; | 1032 | return status; |
1036 | } | 1033 | } |
1037 | 1034 | ||
1035 | static bool find_album_art(int *offset, int *filesize, int *status) | ||
1036 | { | ||
1037 | #ifndef HAVE_ALBUMART | ||
1038 | (void)offset;(void)filesize;(void)status; | ||
1039 | return false; | ||
1040 | #else | ||
1041 | struct mp3entry *current_track = rb->audio_current_track(); | ||
1042 | |||
1043 | if (current_track == NULL) | ||
1044 | { | ||
1045 | return false; | ||
1046 | } | ||
1047 | |||
1048 | switch (current_track->albumart.type) | ||
1049 | { | ||
1050 | case AA_TYPE_BMP: | ||
1051 | (*status) = IMAGE_BMP; | ||
1052 | break; | ||
1053 | case AA_TYPE_PNG: | ||
1054 | (*status) = IMAGE_PNG; | ||
1055 | break; | ||
1056 | case AA_TYPE_JPG: | ||
1057 | (*status) = IMAGE_JPEG; | ||
1058 | break; | ||
1059 | default: | ||
1060 | if (rb->search_albumart_files(current_track, "", np_file, MAX_PATH)) | ||
1061 | { | ||
1062 | (*status) = get_image_type(np_file, false); | ||
1063 | return true; | ||
1064 | } else | ||
1065 | { | ||
1066 | return false; | ||
1067 | } | ||
1068 | } | ||
1069 | rb->strcpy(np_file, current_track->path); | ||
1070 | (*offset) = current_track->albumart.pos; | ||
1071 | (*filesize) = current_track->albumart.size; | ||
1072 | return true; | ||
1073 | #endif | ||
1074 | } | ||
1075 | |||
1038 | /******************** Plugin entry point *********************/ | 1076 | /******************** Plugin entry point *********************/ |
1039 | 1077 | ||
1040 | enum plugin_status plugin_start(const void* parameter) | 1078 | enum plugin_status plugin_start(const void* parameter) |
@@ -1044,13 +1082,28 @@ enum plugin_status plugin_start(const void* parameter) | |||
1044 | long greysize; /* helper */ | 1082 | long greysize; /* helper */ |
1045 | #endif | 1083 | #endif |
1046 | 1084 | ||
1047 | if(!parameter) {rb->splash(HZ*2, "No file"); return PLUGIN_ERROR; } | 1085 | int offset = 0, filesize = 0, status; |
1048 | 1086 | ||
1049 | rb->strcpy(np_file, parameter); | 1087 | bool is_album_art = false; |
1050 | if (get_image_type(np_file, false) == IMAGE_UNKNOWN) | 1088 | if (!parameter) |
1051 | { | 1089 | { |
1052 | rb->splash(HZ*2, "Unsupported file"); | 1090 | if (!find_album_art(&offset, &filesize, &status)) |
1053 | return PLUGIN_ERROR; | 1091 | { |
1092 | rb->splash(HZ * 2, "No file"); | ||
1093 | return PLUGIN_ERROR; | ||
1094 | } | ||
1095 | |||
1096 | entries = 1; | ||
1097 | is_album_art = true; | ||
1098 | } | ||
1099 | else | ||
1100 | { | ||
1101 | rb->strcpy(np_file, parameter); | ||
1102 | if ((status = get_image_type(np_file, false)) == IMAGE_UNKNOWN) | ||
1103 | { | ||
1104 | rb->splash(HZ * 2, "Unsupported file"); | ||
1105 | return PLUGIN_ERROR; | ||
1106 | } | ||
1054 | } | 1107 | } |
1055 | 1108 | ||
1056 | #ifdef USE_PLUG_BUF | 1109 | #ifdef USE_PLUG_BUF |
@@ -1060,7 +1113,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
1060 | buf = rb->plugin_get_audio_buffer(&buf_size); | 1113 | buf = rb->plugin_get_audio_buffer(&buf_size); |
1061 | #endif | 1114 | #endif |
1062 | 1115 | ||
1063 | get_pic_list(); | 1116 | if(!is_album_art) |
1117 | { | ||
1118 | get_pic_list(); | ||
1119 | } | ||
1064 | 1120 | ||
1065 | #ifdef USEGSLIB | 1121 | #ifdef USEGSLIB |
1066 | if (!grey_init(buf, buf_size, GREY_ON_COP, | 1122 | if (!grey_init(buf, buf_size, GREY_ON_COP, |
@@ -1100,8 +1156,18 @@ enum plugin_status plugin_start(const void* parameter) | |||
1100 | 1156 | ||
1101 | do | 1157 | do |
1102 | { | 1158 | { |
1103 | condition = load_and_show(np_file, &image_info); | 1159 | condition = load_and_show(np_file, &image_info, offset, filesize, status); |
1104 | } while (condition >= PLUGIN_OTHER); | 1160 | if (condition >= PLUGIN_OTHER) |
1161 | { | ||
1162 | if(!is_album_art) | ||
1163 | { | ||
1164 | /* suppress warning while running slideshow */ | ||
1165 | status = get_image_type(np_file, iv_api.running_slideshow); | ||
1166 | } | ||
1167 | continue; | ||
1168 | } | ||
1169 | break; | ||
1170 | } while (true); | ||
1105 | release_decoder(); | 1171 | release_decoder(); |
1106 | 1172 | ||
1107 | if (rb->memcmp(&settings, &old_settings, sizeof (settings))) | 1173 | if (rb->memcmp(&settings, &old_settings, sizeof (settings))) |