diff options
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.c | 255 | ||||
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.h | 5 | ||||
-rw-r--r-- | apps/plugins/imageviewer/jpeg/jpeg.c | 10 | ||||
-rw-r--r-- | apps/plugins/imageviewer/png/png.c | 35 |
4 files changed, 143 insertions, 162 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c index c35c1f26be..5c6bcc918f 100644 --- a/apps/plugins/imageviewer/imageviewer.c +++ b/apps/plugins/imageviewer/imageviewer.c | |||
@@ -43,7 +43,7 @@ bool running_slideshow = false; /* loading image because of slideshow */ | |||
43 | #ifdef DISK_SPINDOWN | 43 | #ifdef DISK_SPINDOWN |
44 | bool immediate_ata_off = false; /* power down disk after loading */ | 44 | bool immediate_ata_off = false; /* power down disk after loading */ |
45 | #endif | 45 | #endif |
46 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 46 | #ifdef USE_PLUG_BUF |
47 | /* are we using the plugin buffer or the audio buffer? */ | 47 | /* are we using the plugin buffer or the audio buffer? */ |
48 | bool plug_buf = true; | 48 | bool plug_buf = true; |
49 | #endif | 49 | #endif |
@@ -86,10 +86,6 @@ static struct configdata config[] = | |||
86 | { .int_p = &settings.ss_timeout }, "Slideshow Time", NULL }, | 86 | { .int_p = &settings.ss_timeout }, "Slideshow Time", NULL }, |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #if LCD_DEPTH > 1 | ||
90 | static fb_data* old_backdrop; | ||
91 | #endif | ||
92 | |||
93 | /**************** begin Application ********************/ | 89 | /**************** begin Application ********************/ |
94 | 90 | ||
95 | 91 | ||
@@ -109,11 +105,9 @@ static ssize_t buf_size; | |||
109 | static int ds, ds_min, ds_max; /* downscaling and limits */ | 105 | static int ds, ds_min, ds_max; /* downscaling and limits */ |
110 | static struct image_info image_info; | 106 | static struct image_info image_info; |
111 | 107 | ||
112 | static struct tree_context *tree; | ||
113 | |||
114 | /* the current full file name */ | 108 | /* the current full file name */ |
115 | static char np_file[MAX_PATH]; | 109 | static char np_file[MAX_PATH]; |
116 | static int curfile = 0, direction = DIR_NONE, entries = 0; | 110 | static int curfile = 0, direction = DIR_NEXT, entries = 0; |
117 | 111 | ||
118 | /* list of the supported image files */ | 112 | /* list of the supported image files */ |
119 | static char **file_pt; | 113 | static char **file_pt; |
@@ -123,11 +117,10 @@ static char **file_pt; | |||
123 | /* Read directory contents for scrolling. */ | 117 | /* Read directory contents for scrolling. */ |
124 | static void get_pic_list(void) | 118 | static void get_pic_list(void) |
125 | { | 119 | { |
120 | struct tree_context *tree = rb->tree_get_context(); | ||
121 | struct entry *dircache = tree->dircache; | ||
126 | int i; | 122 | int i; |
127 | struct entry *dircache; | ||
128 | char *pname; | 123 | char *pname; |
129 | tree = rb->tree_get_context(); | ||
130 | dircache = tree->dircache; | ||
131 | 124 | ||
132 | file_pt = (char **) buf; | 125 | file_pt = (char **) buf; |
133 | 126 | ||
@@ -181,15 +174,7 @@ static int change_filename(int direct) | |||
181 | return PLUGIN_ERROR; | 174 | return PLUGIN_ERROR; |
182 | } | 175 | } |
183 | 176 | ||
184 | if (rb->strlen(tree->currdir) > 1) | 177 | rb->strcpy(rb->strrchr(np_file, '/')+1, file_pt[curfile]); |
185 | { | ||
186 | rb->strcpy(np_file, tree->currdir); | ||
187 | rb->strcat(np_file, "/"); | ||
188 | } | ||
189 | else | ||
190 | rb->strcpy(np_file, tree->currdir); | ||
191 | |||
192 | rb->strcat(np_file, file_pt[curfile]); | ||
193 | 178 | ||
194 | return PLUGIN_OTHER; | 179 | return PLUGIN_OTHER; |
195 | } | 180 | } |
@@ -203,12 +188,6 @@ static void cleanup(void *parameter) | |||
203 | #endif | 188 | #endif |
204 | } | 189 | } |
205 | 190 | ||
206 | #define VSCROLL (LCD_HEIGHT/8) | ||
207 | #define HSCROLL (LCD_WIDTH/10) | ||
208 | |||
209 | #define ZOOM_IN 100 /* return codes for below function */ | ||
210 | #define ZOOM_OUT 101 | ||
211 | |||
212 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) | 191 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) |
213 | static bool set_option_grayscale(void) | 192 | static bool set_option_grayscale(void) |
214 | { | 193 | { |
@@ -246,16 +225,6 @@ static void display_options(void) | |||
246 | 225 | ||
247 | static int show_menu(void) /* return 1 to quit */ | 226 | static int show_menu(void) /* return 1 to quit */ |
248 | { | 227 | { |
249 | #if LCD_DEPTH > 1 | ||
250 | rb->lcd_set_backdrop(old_backdrop); | ||
251 | #ifdef HAVE_LCD_COLOR | ||
252 | rb->lcd_set_foreground(rb->global_settings->fg_color); | ||
253 | rb->lcd_set_background(rb->global_settings->bg_color); | ||
254 | #else | ||
255 | rb->lcd_set_foreground(LCD_BLACK); | ||
256 | rb->lcd_set_background(LCD_WHITE); | ||
257 | #endif | ||
258 | #endif | ||
259 | int result; | 228 | int result; |
260 | 229 | ||
261 | enum menu_id | 230 | enum menu_id |
@@ -263,7 +232,7 @@ static int show_menu(void) /* return 1 to quit */ | |||
263 | MIID_RETURN = 0, | 232 | MIID_RETURN = 0, |
264 | MIID_TOGGLE_SS_MODE, | 233 | MIID_TOGGLE_SS_MODE, |
265 | MIID_CHANGE_SS_MODE, | 234 | MIID_CHANGE_SS_MODE, |
266 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 235 | #ifdef USE_PLUG_BUF |
267 | MIID_SHOW_PLAYBACK_MENU, | 236 | MIID_SHOW_PLAYBACK_MENU, |
268 | #endif | 237 | #endif |
269 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) | 238 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) |
@@ -275,7 +244,7 @@ static int show_menu(void) /* return 1 to quit */ | |||
275 | MENUITEM_STRINGLIST(menu, MENU_TITLE, NULL, | 244 | MENUITEM_STRINGLIST(menu, MENU_TITLE, NULL, |
276 | "Return", "Toggle Slideshow Mode", | 245 | "Return", "Toggle Slideshow Mode", |
277 | "Change Slideshow Time", | 246 | "Change Slideshow Time", |
278 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 247 | #ifdef USE_PLUG_BUF |
279 | "Show Playback Menu", | 248 | "Show Playback Menu", |
280 | #endif | 249 | #endif |
281 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) | 250 | #if defined(HAVE_LCD_COLOR) && defined(JPEG_VIEWER) |
@@ -304,7 +273,7 @@ static int show_menu(void) /* return 1 to quit */ | |||
304 | SS_MIN_TIMEOUT, SS_MAX_TIMEOUT, NULL); | 273 | SS_MIN_TIMEOUT, SS_MAX_TIMEOUT, NULL); |
305 | break; | 274 | break; |
306 | 275 | ||
307 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 276 | #ifdef USE_PLUG_BUF |
308 | case MIID_SHOW_PLAYBACK_MENU: | 277 | case MIID_SHOW_PLAYBACK_MENU: |
309 | if (plug_buf) | 278 | if (plug_buf) |
310 | { | 279 | { |
@@ -354,6 +323,88 @@ static int show_menu(void) /* return 1 to quit */ | |||
354 | return 0; | 323 | return 0; |
355 | } | 324 | } |
356 | 325 | ||
326 | #ifdef USE_PLUG_BUF | ||
327 | static int ask_and_get_audio_buffer(const char *filename) | ||
328 | { | ||
329 | rb->lcd_setfont(FONT_SYSFIXED); | ||
330 | rb->lcd_clear_display(); | ||
331 | rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); | ||
332 | rb->lcd_puts(0, 1, "Not enough plugin memory!"); | ||
333 | rb->lcd_puts(0, 2, "Zoom In: Stop playback."); | ||
334 | if(entries > 1) | ||
335 | rb->lcd_puts(0, 3, "Left/Right: Skip File."); | ||
336 | rb->lcd_puts(0, 4, "Show Menu: Quit."); | ||
337 | rb->lcd_update(); | ||
338 | rb->lcd_setfont(FONT_UI); | ||
339 | |||
340 | rb->button_clear_queue(); | ||
341 | |||
342 | while (1) | ||
343 | { | ||
344 | int button = rb->button_get(true); | ||
345 | switch(button) | ||
346 | { | ||
347 | case IMGVIEW_ZOOM_IN: | ||
348 | plug_buf = false; | ||
349 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); | ||
350 | /*try again this file, now using the audio buffer */ | ||
351 | return PLUGIN_OTHER; | ||
352 | #ifdef IMGVIEW_RC_MENU | ||
353 | case IMGVIEW_RC_MENU: | ||
354 | #endif | ||
355 | case IMGVIEW_MENU: | ||
356 | return PLUGIN_OK; | ||
357 | |||
358 | case IMGVIEW_LEFT: | ||
359 | if(entries>1) | ||
360 | { | ||
361 | rb->lcd_clear_display(); | ||
362 | return change_filename(DIR_PREV); | ||
363 | } | ||
364 | break; | ||
365 | |||
366 | case IMGVIEW_RIGHT: | ||
367 | if(entries>1) | ||
368 | { | ||
369 | rb->lcd_clear_display(); | ||
370 | return change_filename(DIR_NEXT); | ||
371 | } | ||
372 | break; | ||
373 | default: | ||
374 | if(rb->default_event_handler_ex(button, cleanup, NULL) | ||
375 | == SYS_USB_CONNECTED) | ||
376 | return PLUGIN_USB_CONNECTED; | ||
377 | |||
378 | } | ||
379 | } | ||
380 | } | ||
381 | #endif /* USE_PLUG_BUF */ | ||
382 | |||
383 | /* callback updating a progress meter while image decoding */ | ||
384 | void cb_progress(int current, int total) | ||
385 | { | ||
386 | rb->yield(); /* be nice to the other threads */ | ||
387 | #ifndef USEGSLIB | ||
388 | /* in slideshow mode, keep gui interference to a minimum */ | ||
389 | const int size = (!running_slideshow ? 8 : 4); | ||
390 | #else | ||
391 | const int size = 8; | ||
392 | if(!running_slideshow) | ||
393 | #endif | ||
394 | { | ||
395 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], | ||
396 | 0, LCD_HEIGHT-size, LCD_WIDTH, size, | ||
397 | total, 0, current, HORIZONTAL); | ||
398 | rb->lcd_update_rect(0, LCD_HEIGHT-size, LCD_WIDTH, size); | ||
399 | } | ||
400 | } | ||
401 | |||
402 | #define VSCROLL (LCD_HEIGHT/8) | ||
403 | #define HSCROLL (LCD_WIDTH/10) | ||
404 | |||
405 | #define ZOOM_IN 100 /* return codes for below function */ | ||
406 | #define ZOOM_OUT 101 | ||
407 | |||
357 | /* Pan the viewing window right - move image to the left and fill in | 408 | /* Pan the viewing window right - move image to the left and fill in |
358 | the right-hand side */ | 409 | the right-hand side */ |
359 | static void pan_view_right(struct image_info *info) | 410 | static void pan_view_right(struct image_info *info) |
@@ -454,7 +505,7 @@ static void pan_view_down(struct image_info *info) | |||
454 | static int scroll_bmp(struct image_info *info) | 505 | static int scroll_bmp(struct image_info *info) |
455 | { | 506 | { |
456 | int button; | 507 | int button; |
457 | int lastbutton = 0; | 508 | int lastbutton = BUTTON_NONE; |
458 | 509 | ||
459 | while (true) | 510 | while (true) |
460 | { | 511 | { |
@@ -494,17 +545,16 @@ static int scroll_bmp(struct image_info *info) | |||
494 | break; | 545 | break; |
495 | 546 | ||
496 | case BUTTON_NONE: | 547 | case BUTTON_NONE: |
497 | if (!slideshow_enabled) | 548 | if (slideshow_enabled && entries > 1) |
498 | break; | 549 | { |
499 | running_slideshow = true; | 550 | running_slideshow = true; |
500 | if (entries > 1) | ||
501 | return change_filename(DIR_NEXT); | 551 | return change_filename(DIR_NEXT); |
552 | } | ||
502 | break; | 553 | break; |
503 | 554 | ||
504 | #ifdef IMGVIEW_SLIDE_SHOW | 555 | #ifdef IMGVIEW_SLIDE_SHOW |
505 | case IMGVIEW_SLIDE_SHOW: | 556 | case IMGVIEW_SLIDE_SHOW: |
506 | slideshow_enabled = !slideshow_enabled; | 557 | slideshow_enabled = !slideshow_enabled; |
507 | running_slideshow = slideshow_enabled; | ||
508 | break; | 558 | break; |
509 | #endif | 559 | #endif |
510 | 560 | ||
@@ -539,6 +589,7 @@ static int scroll_bmp(struct image_info *info) | |||
539 | #endif | 589 | #endif |
540 | return ZOOM_OUT; | 590 | return ZOOM_OUT; |
541 | break; | 591 | break; |
592 | |||
542 | #ifdef IMGVIEW_RC_MENU | 593 | #ifdef IMGVIEW_RC_MENU |
543 | case IMGVIEW_RC_MENU: | 594 | case IMGVIEW_RC_MENU: |
544 | #endif | 595 | #endif |
@@ -557,6 +608,7 @@ static int scroll_bmp(struct image_info *info) | |||
557 | MYLCD_UPDATE(); | 608 | MYLCD_UPDATE(); |
558 | #endif | 609 | #endif |
559 | break; | 610 | break; |
611 | |||
560 | default: | 612 | default: |
561 | if (rb->default_event_handler_ex(button, cleanup, NULL) | 613 | if (rb->default_event_handler_ex(button, cleanup, NULL) |
562 | == SYS_USB_CONNECTED) | 614 | == SYS_USB_CONNECTED) |
@@ -572,29 +624,6 @@ static int scroll_bmp(struct image_info *info) | |||
572 | 624 | ||
573 | /********************* main function *************************/ | 625 | /********************* main function *************************/ |
574 | 626 | ||
575 | /* callback updating a progress meter while image decoding */ | ||
576 | void cb_progress(int current, int total) | ||
577 | { | ||
578 | rb->yield(); /* be nice to the other threads */ | ||
579 | if(!running_slideshow) | ||
580 | { | ||
581 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], | ||
582 | 0, LCD_HEIGHT-8, LCD_WIDTH, 8, | ||
583 | total, 0, current, HORIZONTAL); | ||
584 | rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8); | ||
585 | } | ||
586 | #ifndef USEGSLIB | ||
587 | else | ||
588 | { | ||
589 | /* in slideshow mode, keep gui interference to a minimum */ | ||
590 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], | ||
591 | 0, LCD_HEIGHT-4, LCD_WIDTH, 4, | ||
592 | total, 0, current, HORIZONTAL); | ||
593 | rb->lcd_update_rect(0, LCD_HEIGHT-4, LCD_WIDTH, 4); | ||
594 | } | ||
595 | #endif | ||
596 | } | ||
597 | |||
598 | /* how far can we zoom in without running out of memory */ | 627 | /* how far can we zoom in without running out of memory */ |
599 | static int min_downscale(int bufsize) | 628 | static int min_downscale(int bufsize) |
600 | { | 629 | { |
@@ -658,11 +687,6 @@ static int load_and_show(char* filename, struct image_info *info) | |||
658 | int cx, cy; | 687 | int cx, cy; |
659 | ssize_t remaining; | 688 | ssize_t remaining; |
660 | 689 | ||
661 | #if LCD_DEPTH > 1 | ||
662 | rb->lcd_set_foreground(LCD_WHITE); | ||
663 | rb->lcd_set_background(LCD_BLACK); | ||
664 | rb->lcd_set_backdrop(NULL); | ||
665 | #endif | ||
666 | rb->lcd_clear_display(); | 690 | rb->lcd_clear_display(); |
667 | 691 | ||
668 | rb->memset(info, 0, sizeof(*info)); | 692 | rb->memset(info, 0, sizeof(*info)); |
@@ -675,61 +699,10 @@ static int load_and_show(char* filename, struct image_info *info) | |||
675 | 699 | ||
676 | if (status == PLUGIN_OUTOFMEM) | 700 | if (status == PLUGIN_OUTOFMEM) |
677 | { | 701 | { |
678 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 702 | #ifdef USE_PLUG_BUF |
679 | if(plug_buf) | 703 | if(plug_buf) |
680 | { | 704 | { |
681 | rb->lcd_setfont(FONT_SYSFIXED); | 705 | return ask_and_get_audio_buffer(filename); |
682 | rb->lcd_clear_display(); | ||
683 | rb->snprintf(print,sizeof(print),"%s:",rb->strrchr(filename,'/')+1); | ||
684 | rb->lcd_puts(0,0,print); | ||
685 | rb->lcd_puts(0,1,"Not enough plugin memory!"); | ||
686 | rb->lcd_puts(0,2,"Zoom In: Stop playback."); | ||
687 | if(entries>1) | ||
688 | rb->lcd_puts(0,3,"Left/Right: Skip File."); | ||
689 | rb->lcd_puts(0,4,"Show Menu: Quit."); | ||
690 | rb->lcd_update(); | ||
691 | rb->lcd_setfont(FONT_UI); | ||
692 | |||
693 | rb->button_clear_queue(); | ||
694 | |||
695 | while (1) | ||
696 | { | ||
697 | int button = rb->button_get(true); | ||
698 | switch(button) | ||
699 | { | ||
700 | case IMGVIEW_ZOOM_IN: | ||
701 | plug_buf = false; | ||
702 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); | ||
703 | /*try again this file, now using the audio buffer */ | ||
704 | return PLUGIN_OTHER; | ||
705 | #ifdef IMGVIEW_RC_MENU | ||
706 | case IMGVIEW_RC_MENU: | ||
707 | #endif | ||
708 | case IMGVIEW_MENU: | ||
709 | return PLUGIN_OK; | ||
710 | |||
711 | case IMGVIEW_LEFT: | ||
712 | if(entries>1) | ||
713 | { | ||
714 | rb->lcd_clear_display(); | ||
715 | return change_filename(DIR_PREV); | ||
716 | } | ||
717 | break; | ||
718 | |||
719 | case IMGVIEW_RIGHT: | ||
720 | if(entries>1) | ||
721 | { | ||
722 | rb->lcd_clear_display(); | ||
723 | return change_filename(DIR_NEXT); | ||
724 | } | ||
725 | break; | ||
726 | default: | ||
727 | if(rb->default_event_handler_ex(button, cleanup, NULL) | ||
728 | == SYS_USB_CONNECTED) | ||
729 | return PLUGIN_USB_CONNECTED; | ||
730 | |||
731 | } | ||
732 | } | ||
733 | } | 706 | } |
734 | else | 707 | else |
735 | #endif | 708 | #endif |
@@ -758,9 +731,18 @@ static int load_and_show(char* filename, struct image_info *info) | |||
758 | ds_min = ds_max = 1; | 731 | ds_min = ds_max = 1; |
759 | #else | 732 | #else |
760 | /* not enough memory to decode image. */ | 733 | /* not enough memory to decode image. */ |
761 | rb->splash(HZ, "too large"); | 734 | #ifdef USE_PLUG_BUF |
762 | file_pt[curfile] = NULL; | 735 | if(plug_buf) |
763 | return change_filename(direction); | 736 | { |
737 | return ask_and_get_audio_buffer(filename); | ||
738 | } | ||
739 | else | ||
740 | #endif | ||
741 | { | ||
742 | rb->splash(HZ, "too large"); | ||
743 | file_pt[curfile] = NULL; | ||
744 | return change_filename(direction); | ||
745 | } | ||
764 | #endif | 746 | #endif |
765 | } | 747 | } |
766 | else if (ds_max < ds_min) | 748 | else if (ds_max < ds_min) |
@@ -784,7 +766,7 @@ static int load_and_show(char* filename, struct image_info *info) | |||
784 | if(!running_slideshow) | 766 | if(!running_slideshow) |
785 | { | 767 | { |
786 | rb->snprintf(print, sizeof(print), "showing %dx%d", | 768 | rb->snprintf(print, sizeof(print), "showing %dx%d", |
787 | info->width, info->height); | 769 | info->width, info->height); |
788 | rb->lcd_puts(0, 3, print); | 770 | rb->lcd_puts(0, 3, print); |
789 | rb->lcd_update(); | 771 | rb->lcd_update(); |
790 | } | 772 | } |
@@ -869,13 +851,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
869 | #ifdef USEGSLIB | 851 | #ifdef USEGSLIB |
870 | long greysize; /* helper */ | 852 | long greysize; /* helper */ |
871 | #endif | 853 | #endif |
872 | #if LCD_DEPTH > 1 | ||
873 | old_backdrop = rb->lcd_get_backdrop(); | ||
874 | #endif | ||
875 | 854 | ||
876 | if(!parameter) return PLUGIN_ERROR; | 855 | if(!parameter) return PLUGIN_ERROR; |
877 | 856 | ||
878 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 857 | #ifdef USE_PLUG_BUF |
879 | buf = rb->plugin_get_buffer((size_t *)&buf_size); | 858 | buf = rb->plugin_get_buffer((size_t *)&buf_size); |
880 | #else | 859 | #else |
881 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); | 860 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); |
@@ -886,7 +865,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
886 | 865 | ||
887 | if(!entries) return PLUGIN_ERROR; | 866 | if(!entries) return PLUGIN_ERROR; |
888 | 867 | ||
889 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 868 | #ifdef USE_PLUG_BUF |
890 | if(!rb->audio_status()) | 869 | if(!rb->audio_status()) |
891 | { | 870 | { |
892 | plug_buf = false; | 871 | plug_buf = false; |
@@ -914,6 +893,12 @@ enum plugin_status plugin_start(const void* parameter) | |||
914 | /* Turn off backlight timeout */ | 893 | /* Turn off backlight timeout */ |
915 | backlight_force_on(); /* backlight control in lib/helper.c */ | 894 | backlight_force_on(); /* backlight control in lib/helper.c */ |
916 | 895 | ||
896 | #if LCD_DEPTH > 1 | ||
897 | rb->lcd_set_backdrop(NULL); | ||
898 | rb->lcd_set_foreground(LCD_WHITE); | ||
899 | rb->lcd_set_background(LCD_BLACK); | ||
900 | #endif | ||
901 | |||
917 | do | 902 | do |
918 | { | 903 | { |
919 | condition = load_and_show(np_file, &image_info); | 904 | condition = load_and_show(np_file, &image_info); |
diff --git a/apps/plugins/imageviewer/imageviewer.h b/apps/plugins/imageviewer/imageviewer.h index 4ced196e59..e1009ec32f 100644 --- a/apps/plugins/imageviewer/imageviewer.h +++ b/apps/plugins/imageviewer/imageviewer.h | |||
@@ -361,6 +361,9 @@ | |||
361 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) | 361 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) |
362 | #define DISK_SPINDOWN | 362 | #define DISK_SPINDOWN |
363 | #endif | 363 | #endif |
364 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | ||
365 | #define USE_PLUG_BUF | ||
366 | #endif | ||
364 | 367 | ||
365 | /* Settings. jpeg needs these */ | 368 | /* Settings. jpeg needs these */ |
366 | struct imgview_settings | 369 | struct imgview_settings |
@@ -390,7 +393,7 @@ extern bool running_slideshow; | |||
390 | #ifdef DISK_SPINDOWN | 393 | #ifdef DISK_SPINDOWN |
391 | extern bool immediate_ata_off; | 394 | extern bool immediate_ata_off; |
392 | #endif | 395 | #endif |
393 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 396 | #ifdef USE_PLUG_BUF |
394 | extern bool plug_buf; | 397 | extern bool plug_buf; |
395 | #endif | 398 | #endif |
396 | 399 | ||
diff --git a/apps/plugins/imageviewer/jpeg/jpeg.c b/apps/plugins/imageviewer/jpeg/jpeg.c index b4ac6c0fce..91e0c1021f 100644 --- a/apps/plugins/imageviewer/jpeg/jpeg.c +++ b/apps/plugins/imageviewer/jpeg/jpeg.c | |||
@@ -156,8 +156,7 @@ int load_image(char *filename, struct image_info *info, | |||
156 | 156 | ||
157 | if(!running_slideshow) | 157 | if(!running_slideshow) |
158 | { | 158 | { |
159 | rb->snprintf(print, sizeof(print), "%s:", rb->strrchr(filename,'/')+1); | 159 | rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); |
160 | rb->lcd_puts(0, 0, print); | ||
161 | rb->lcd_update(); | 160 | rb->lcd_update(); |
162 | 161 | ||
163 | rb->snprintf(print, sizeof(print), "loading %d bytes", filesize); | 162 | rb->snprintf(print, sizeof(print), "loading %d bytes", filesize); |
@@ -170,8 +169,7 @@ int load_image(char *filename, struct image_info *info, | |||
170 | 169 | ||
171 | if(!running_slideshow) | 170 | if(!running_slideshow) |
172 | { | 171 | { |
173 | rb->snprintf(print, sizeof(print), "decoding markers"); | 172 | rb->lcd_puts(0, 2, "decoding markers"); |
174 | rb->lcd_puts(0, 2, print); | ||
175 | rb->lcd_update(); | 173 | rb->lcd_update(); |
176 | } | 174 | } |
177 | #ifdef DISK_SPINDOWN | 175 | #ifdef DISK_SPINDOWN |
@@ -198,7 +196,7 @@ int load_image(char *filename, struct image_info *info, | |||
198 | if(!running_slideshow) | 196 | if(!running_slideshow) |
199 | { | 197 | { |
200 | rb->snprintf(print, sizeof(print), "image %dx%d", | 198 | rb->snprintf(print, sizeof(print), "image %dx%d", |
201 | p_jpg->x_size, p_jpg->y_size); | 199 | p_jpg->x_size, p_jpg->y_size); |
202 | rb->lcd_puts(0, 2, print); | 200 | rb->lcd_puts(0, 2, print); |
203 | rb->lcd_update(); | 201 | rb->lcd_update(); |
204 | } | 202 | } |
@@ -272,7 +270,7 @@ int get_image(struct image_info *info, int ds) | |||
272 | if(!running_slideshow) | 270 | if(!running_slideshow) |
273 | { | 271 | { |
274 | rb->snprintf(print, sizeof(print), "decoding %d*%d", | 272 | rb->snprintf(print, sizeof(print), "decoding %d*%d", |
275 | p_jpg->x_size/ds, p_jpg->y_size/ds); | 273 | info->width, info->height); |
276 | rb->lcd_puts(0, 3, print); | 274 | rb->lcd_puts(0, 3, print); |
277 | rb->lcd_update(); | 275 | rb->lcd_update(); |
278 | } | 276 | } |
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c index d04b0850f4..958793b37d 100644 --- a/apps/plugins/imageviewer/png/png.c +++ b/apps/plugins/imageviewer/png/png.c | |||
@@ -144,7 +144,7 @@ static fb_data *disp[9]; | |||
144 | static fb_data *disp_buf; | 144 | static fb_data *disp_buf; |
145 | 145 | ||
146 | /* my memory pool (from the mp3 buffer) */ | 146 | /* my memory pool (from the mp3 buffer) */ |
147 | static char print[128]; /* use a common snprintf() buffer */ | 147 | static char print[32]; /* use a common snprintf() buffer */ |
148 | 148 | ||
149 | unsigned char *memory, *memory_max; /* inffast.c needs memory_max */ | 149 | unsigned char *memory, *memory_max; /* inffast.c needs memory_max */ |
150 | static size_t memory_size; | 150 | static size_t memory_size; |
@@ -204,7 +204,6 @@ static unsigned LodePNG_decompress(unsigned char* out, size_t* outsize, const un | |||
204 | if (stream.msg != Z_NULL) | 204 | if (stream.msg != Z_NULL) |
205 | rb->strcpy(error_msg, stream.msg); | 205 | rb->strcpy(error_msg, stream.msg); |
206 | return err; | 206 | return err; |
207 | |||
208 | } | 207 | } |
209 | 208 | ||
210 | /* ////////////////////////////////////////////////////////////////////////// */ | 209 | /* ////////////////////////////////////////////////////////////////////////// */ |
@@ -469,8 +468,7 @@ unsigned LodePNG_convert(fb_data* out, const unsigned char* in, LodePNG_InfoColo | |||
469 | 468 | ||
470 | if (!running_slideshow) | 469 | if (!running_slideshow) |
471 | { | 470 | { |
472 | rb->snprintf(print, sizeof(print), "color conversion in progress"); | 471 | rb->lcd_puts(0, 3, "color conversion in progress"); |
473 | rb->lcd_puts(0, 3, print); | ||
474 | rb->lcd_update(); | 472 | rb->lcd_update(); |
475 | } | 473 | } |
476 | 474 | ||
@@ -1201,8 +1199,7 @@ static void decodeGeneric(LodePNG_Decoder* decoder, unsigned char* in, size_t si | |||
1201 | memset(decoded_image, 0, decoded_image_size * sizeof(unsigned char)); | 1199 | memset(decoded_image, 0, decoded_image_size * sizeof(unsigned char)); |
1202 | if (!running_slideshow) | 1200 | if (!running_slideshow) |
1203 | { | 1201 | { |
1204 | rb->snprintf(print, sizeof(print), "unfiltering scanlines"); | 1202 | rb->lcd_puts(0, 3, "unfiltering scanlines"); |
1205 | rb->lcd_puts(0, 3, print); | ||
1206 | rb->lcd_update(); | 1203 | rb->lcd_update(); |
1207 | } | 1204 | } |
1208 | decoder->error = postProcessScanlines(decoded_image, scanlines, decoder); | 1205 | decoder->error = postProcessScanlines(decoded_image, scanlines, decoder); |
@@ -1217,7 +1214,7 @@ void LodePNG_decode(LodePNG_Decoder* decoder, unsigned char* in, size_t insize, | |||
1217 | 1214 | ||
1218 | /*TODO: check if this works according to the statement in the documentation: "The converter can convert from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/ | 1215 | /*TODO: check if this works according to the statement in the documentation: "The converter can convert from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/ |
1219 | if (!(decoder->infoRaw.color.colorType == 2 || decoder->infoRaw.color.colorType == 6) && !(decoder->infoRaw.color.bitDepth == 8)) { decoder->error = 56; return; } | 1216 | if (!(decoder->infoRaw.color.colorType == 2 || decoder->infoRaw.color.colorType == 6) && !(decoder->infoRaw.color.bitDepth == 8)) { decoder->error = 56; return; } |
1220 | converted_image = (fb_data *)((intptr_t)(memory + 3) & ~3); | 1217 | converted_image = (fb_data *)memory; |
1221 | converted_image_size = decoder->infoPng.width*decoder->infoPng.height; | 1218 | converted_image_size = decoder->infoPng.width*decoder->infoPng.height; |
1222 | if ((unsigned char *)(converted_image + converted_image_size) >= decoded_image) { decoder->error = OUT_OF_MEMORY; } | 1219 | if ((unsigned char *)(converted_image + converted_image_size) >= decoded_image) { decoder->error = OUT_OF_MEMORY; } |
1223 | if (!decoder->error) decoder->error = LodePNG_convert(converted_image, decoded_image, &decoder->infoRaw.color, &decoder->infoPng.color, decoder->infoPng.width, decoder->infoPng.height); | 1220 | if (!decoder->error) decoder->error = LodePNG_convert(converted_image, decoded_image, &decoder->infoRaw.color, &decoder->infoPng.color, decoder->infoPng.width, decoder->infoPng.height); |
@@ -1333,9 +1330,10 @@ int load_image(char *filename, struct image_info *info, | |||
1333 | memset(&disp, 0, sizeof(disp)); | 1330 | memset(&disp, 0, sizeof(disp)); |
1334 | LodePNG_Decoder_init(decoder); | 1331 | LodePNG_Decoder_init(decoder); |
1335 | 1332 | ||
1336 | memory = buf; | 1333 | /* align buffer */ |
1337 | memory_size = *buf_size; | 1334 | memory = (unsigned char *)((intptr_t)(buf + 3) & ~3); |
1338 | memory_max = memory + memory_size; | 1335 | memory_max = (unsigned char *)((intptr_t)(memory + *buf_size) & ~3); |
1336 | memory_size = memory_max - memory; | ||
1339 | 1337 | ||
1340 | fd = rb->open(filename, O_RDONLY); | 1338 | fd = rb->open(filename, O_RDONLY); |
1341 | if (fd < 0) | 1339 | if (fd < 0) |
@@ -1348,8 +1346,7 @@ int load_image(char *filename, struct image_info *info, | |||
1348 | DEBUGF("reading file '%s'\n", filename); | 1346 | DEBUGF("reading file '%s'\n", filename); |
1349 | 1347 | ||
1350 | if (!running_slideshow) { | 1348 | if (!running_slideshow) { |
1351 | rb->snprintf(print, sizeof(print), "%s:", rb->strrchr(filename,'/')+1); | 1349 | rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); |
1352 | rb->lcd_puts(0, 0, print); | ||
1353 | rb->lcd_update(); | 1350 | rb->lcd_update(); |
1354 | } | 1351 | } |
1355 | 1352 | ||
@@ -1369,8 +1366,7 @@ int load_image(char *filename, struct image_info *info, | |||
1369 | rb->close(fd); | 1366 | rb->close(fd); |
1370 | 1367 | ||
1371 | if (!running_slideshow) { | 1368 | if (!running_slideshow) { |
1372 | rb->snprintf(print, sizeof(print), "decoding image"); | 1369 | rb->lcd_puts(0, 2, "decoding image"); |
1373 | rb->lcd_puts(0, 2, print); | ||
1374 | rb->lcd_update(); | 1370 | rb->lcd_update(); |
1375 | } | 1371 | } |
1376 | #ifdef DISK_SPINDOWN | 1372 | #ifdef DISK_SPINDOWN |
@@ -1409,11 +1405,10 @@ int load_image(char *filename, struct image_info *info, | |||
1409 | #else | 1405 | #else |
1410 | LodePNG_decode(decoder, image, image_size, cb_progress); | 1406 | LodePNG_decode(decoder, image, image_size, cb_progress); |
1411 | #endif /*HAVE_ADJUSTABLE_CPU_FREQ*/ | 1407 | #endif /*HAVE_ADJUSTABLE_CPU_FREQ*/ |
1408 | time = *rb->current_tick - time; | ||
1412 | } | 1409 | } |
1413 | } | 1410 | } |
1414 | 1411 | ||
1415 | time = *rb->current_tick - time; | ||
1416 | |||
1417 | if (!running_slideshow && !decoder->error) | 1412 | if (!running_slideshow && !decoder->error) |
1418 | { | 1413 | { |
1419 | rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); | 1414 | rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); |
@@ -1423,7 +1418,7 @@ int load_image(char *filename, struct image_info *info, | |||
1423 | } | 1418 | } |
1424 | 1419 | ||
1425 | if (decoder->error) { | 1420 | if (decoder->error) { |
1426 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 1421 | #ifdef USE_PLUG_BUF |
1427 | if (plug_buf && (decoder->error == FILE_TOO_LARGE | 1422 | if (plug_buf && (decoder->error == FILE_TOO_LARGE |
1428 | || decoder->error == OUT_OF_MEMORY || decoder->error == Z_MEM_ERROR)) | 1423 | || decoder->error == OUT_OF_MEMORY || decoder->error == Z_MEM_ERROR)) |
1429 | return PLUGIN_OUTOFMEM; | 1424 | return PLUGIN_OUTOFMEM; |
@@ -1457,7 +1452,7 @@ int load_image(char *filename, struct image_info *info, | |||
1457 | return PLUGIN_ERROR; | 1452 | return PLUGIN_ERROR; |
1458 | } | 1453 | } |
1459 | 1454 | ||
1460 | disp_buf = (fb_data *)((intptr_t)(converted_image + converted_image_size + 3) & ~3); | 1455 | disp_buf = converted_image + converted_image_size; |
1461 | info->x_size = decoder->infoPng.width; | 1456 | info->x_size = decoder->infoPng.width; |
1462 | info->y_size = decoder->infoPng.height; | 1457 | info->y_size = decoder->infoPng.height; |
1463 | *buf_size = memory_max - (unsigned char*)disp_buf; | 1458 | *buf_size = memory_max - (unsigned char*)disp_buf; |
@@ -1498,11 +1493,11 @@ int get_image(struct image_info *info, int ds) | |||
1498 | for (i=1; i<=8; i++) | 1493 | for (i=1; i<=8; i++) |
1499 | disp[i] = NULL; /* invalidate all bitmaps */ | 1494 | disp[i] = NULL; /* invalidate all bitmaps */ |
1500 | /* start again from the beginning of the buffer */ | 1495 | /* start again from the beginning of the buffer */ |
1501 | disp_buf = (fb_data *)((intptr_t)(converted_image + converted_image_size + 3) & ~3); | 1496 | disp_buf = converted_image + converted_image_size; |
1502 | } | 1497 | } |
1503 | 1498 | ||
1504 | *p_disp = disp_buf; | 1499 | *p_disp = disp_buf; |
1505 | disp_buf = (fb_data *)((intptr_t)(disp_buf + size + 3) & ~3); | 1500 | disp_buf += size; |
1506 | 1501 | ||
1507 | bmp_src.width = decoder->infoPng.width; | 1502 | bmp_src.width = decoder->infoPng.width; |
1508 | bmp_src.height = decoder->infoPng.height; | 1503 | bmp_src.height = decoder->infoPng.height; |