diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/jpeg/jpeg.c | 109 | ||||
-rw-r--r-- | apps/plugins/png/png.c | 69 |
2 files changed, 57 insertions, 121 deletions
diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index fc98834a7d..807c6c4101 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c | |||
@@ -445,6 +445,25 @@ int show_menu(void) /* return 1 to quit */ | |||
445 | return 0; | 445 | return 0; |
446 | } | 446 | } |
447 | 447 | ||
448 | void draw_image_rect(struct t_disp* pdisp, int x, int y, int width, int height) | ||
449 | { | ||
450 | #ifdef HAVE_LCD_COLOR | ||
451 | yuv_bitmap_part( | ||
452 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, | ||
453 | pdisp->x + x, pdisp->y + y, pdisp->stride, | ||
454 | x + MAX(0, (LCD_WIDTH - pdisp->width) / 2), | ||
455 | y + MAX(0, (LCD_HEIGHT - pdisp->height) / 2), | ||
456 | width, height, | ||
457 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
458 | #else | ||
459 | MYXLCD(gray_bitmap_part)( | ||
460 | pdisp->bitmap[0], pdisp->x + x, pdisp->y + y, pdisp->stride, | ||
461 | x + MAX(0, (LCD_WIDTH-pdisp->width)/2), | ||
462 | y + MAX(0, (LCD_HEIGHT-pdisp->height)/2), | ||
463 | width, height); | ||
464 | #endif | ||
465 | } | ||
466 | |||
448 | /* Pan the viewing window right - move image to the left and fill in | 467 | /* Pan the viewing window right - move image to the left and fill in |
449 | the right-hand side */ | 468 | the right-hand side */ |
450 | static void pan_view_right(struct t_disp* pdisp) | 469 | static void pan_view_right(struct t_disp* pdisp) |
@@ -456,20 +475,7 @@ static void pan_view_right(struct t_disp* pdisp) | |||
456 | { | 475 | { |
457 | MYXLCD(scroll_left)(move); /* scroll left */ | 476 | MYXLCD(scroll_left)(move); /* scroll left */ |
458 | pdisp->x += move; | 477 | pdisp->x += move; |
459 | #ifdef HAVE_LCD_COLOR | 478 | draw_image_rect(pdisp, LCD_WIDTH - move, 0, move, pdisp->height-pdisp->y); |
460 | yuv_bitmap_part( | ||
461 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, | ||
462 | pdisp->x + LCD_WIDTH - move, pdisp->y, pdisp->stride, | ||
463 | LCD_WIDTH - move, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | ||
464 | move, MIN(LCD_HEIGHT, pdisp->height), /* w, h */ | ||
465 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
466 | #else | ||
467 | MYXLCD(gray_bitmap_part)( | ||
468 | pdisp->bitmap[0], pdisp->x + LCD_WIDTH - move, | ||
469 | pdisp->y, pdisp->stride, | ||
470 | LCD_WIDTH - move, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | ||
471 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ | ||
472 | #endif | ||
473 | MYLCD_UPDATE(); | 479 | MYLCD_UPDATE(); |
474 | } | 480 | } |
475 | } | 481 | } |
@@ -485,24 +491,11 @@ static void pan_view_left(struct t_disp* pdisp) | |||
485 | { | 491 | { |
486 | MYXLCD(scroll_right)(move); /* scroll right */ | 492 | MYXLCD(scroll_right)(move); /* scroll right */ |
487 | pdisp->x -= move; | 493 | pdisp->x -= move; |
488 | #ifdef HAVE_LCD_COLOR | 494 | draw_image_rect(pdisp, 0, 0, move, pdisp->height-pdisp->y); |
489 | yuv_bitmap_part( | ||
490 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, | ||
491 | pdisp->x, pdisp->y, pdisp->stride, | ||
492 | 0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | ||
493 | move, MIN(LCD_HEIGHT, pdisp->height), /* w, h */ | ||
494 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
495 | #else | ||
496 | MYXLCD(gray_bitmap_part)( | ||
497 | pdisp->bitmap[0], pdisp->x, pdisp->y, pdisp->stride, | ||
498 | 0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | ||
499 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ | ||
500 | #endif | ||
501 | MYLCD_UPDATE(); | 495 | MYLCD_UPDATE(); |
502 | } | 496 | } |
503 | } | 497 | } |
504 | 498 | ||
505 | |||
506 | /* Pan the viewing window up - move image down and fill in | 499 | /* Pan the viewing window up - move image down and fill in |
507 | the top */ | 500 | the top */ |
508 | static void pan_view_up(struct t_disp* pdisp) | 501 | static void pan_view_up(struct t_disp* pdisp) |
@@ -521,19 +514,8 @@ static void pan_view_up(struct t_disp* pdisp) | |||
521 | caused by lack of error history on line zero. */ | 514 | caused by lack of error history on line zero. */ |
522 | move = MIN(move + 1, pdisp->y + pdisp->height); | 515 | move = MIN(move + 1, pdisp->y + pdisp->height); |
523 | } | 516 | } |
524 | |||
525 | yuv_bitmap_part( | ||
526 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, | ||
527 | pdisp->x, pdisp->y, pdisp->stride, | ||
528 | MAX(0, (LCD_WIDTH-pdisp->width)/2), 0, /* x, y */ | ||
529 | MIN(LCD_WIDTH, pdisp->width), move, /* w, h */ | ||
530 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
531 | #else | ||
532 | MYXLCD(gray_bitmap_part)( | ||
533 | pdisp->bitmap[0], pdisp->x, pdisp->y, pdisp->stride, | ||
534 | MAX(0, (LCD_WIDTH-pdisp->width)/2), 0, /* x, y */ | ||
535 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ | ||
536 | #endif | 517 | #endif |
518 | draw_image_rect(pdisp, 0, 0, pdisp->width-pdisp->x, move); | ||
537 | MYLCD_UPDATE(); | 519 | MYLCD_UPDATE(); |
538 | } | 520 | } |
539 | } | 521 | } |
@@ -561,14 +543,11 @@ static void pan_view_down(struct t_disp* pdisp) | |||
561 | rb->lcd_framebuffer + (LCD_HEIGHT - move)*LCD_WIDTH, | 543 | rb->lcd_framebuffer + (LCD_HEIGHT - move)*LCD_WIDTH, |
562 | LCD_WIDTH*sizeof (fb_data)); | 544 | LCD_WIDTH*sizeof (fb_data)); |
563 | } | 545 | } |
546 | #endif | ||
564 | 547 | ||
565 | yuv_bitmap_part( | 548 | draw_image_rect(pdisp, 0, LCD_HEIGHT - move, pdisp->width-pdisp->x, move); |
566 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, pdisp->x, | ||
567 | pdisp->y + LCD_HEIGHT - move, pdisp->stride, | ||
568 | MAX(0, (LCD_WIDTH-pdisp->width)/2), LCD_HEIGHT - move, /* x, y */ | ||
569 | MIN(LCD_WIDTH, pdisp->width), move, /* w, h */ | ||
570 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
571 | 549 | ||
550 | #ifdef HAVE_LCD_COLOR | ||
572 | if (jpeg_settings.dither_mode == DITHER_DIFFUSION) | 551 | if (jpeg_settings.dither_mode == DITHER_DIFFUSION) |
573 | { | 552 | { |
574 | /* Cover the first row drawn with previous image data. */ | 553 | /* Cover the first row drawn with previous image data. */ |
@@ -577,12 +556,6 @@ static void pan_view_down(struct t_disp* pdisp) | |||
577 | LCD_WIDTH*sizeof (fb_data)); | 556 | LCD_WIDTH*sizeof (fb_data)); |
578 | pdisp->y++; | 557 | pdisp->y++; |
579 | } | 558 | } |
580 | #else | ||
581 | MYXLCD(gray_bitmap_part)( | ||
582 | pdisp->bitmap[0], pdisp->x, | ||
583 | pdisp->y + LCD_HEIGHT - move, pdisp->stride, | ||
584 | MAX(0, (LCD_WIDTH-pdisp->width)/2), LCD_HEIGHT - move, /* x, y */ | ||
585 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ | ||
586 | #endif | 559 | #endif |
587 | MYLCD_UPDATE(); | 560 | MYLCD_UPDATE(); |
588 | } | 561 | } |
@@ -687,14 +660,8 @@ int scroll_bmp(struct t_disp* pdisp) | |||
687 | #ifdef USEGSLIB | 660 | #ifdef USEGSLIB |
688 | grey_show(true); /* switch on greyscale overlay */ | 661 | grey_show(true); /* switch on greyscale overlay */ |
689 | #else | 662 | #else |
690 | yuv_bitmap_part( | 663 | draw_image_rect(pdisp, 0, 0, |
691 | pdisp->bitmap, pdisp->csub_x, pdisp->csub_y, | 664 | pdisp->width-pdisp->x, pdisp->height-pdisp->y); |
692 | pdisp->x, pdisp->y, pdisp->stride, | ||
693 | MAX(0, (LCD_WIDTH - pdisp->width) / 2), | ||
694 | MAX(0, (LCD_HEIGHT - pdisp->height) / 2), | ||
695 | MIN(LCD_WIDTH, pdisp->width), | ||
696 | MIN(LCD_HEIGHT, pdisp->height), | ||
697 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
698 | MYLCD_UPDATE(); | 665 | MYLCD_UPDATE(); |
699 | #endif | 666 | #endif |
700 | break; | 667 | break; |
@@ -1072,7 +1039,7 @@ int load_and_show(char* filename) | |||
1072 | return change_filename(direction); | 1039 | return change_filename(direction); |
1073 | } | 1040 | } |
1074 | 1041 | ||
1075 | ds = ds_max; /* initials setting */ | 1042 | ds = ds_max; /* initialize setting */ |
1076 | cx = jpg.x_size/ds/2; /* center the view */ | 1043 | cx = jpg.x_size/ds/2; /* center the view */ |
1077 | cy = jpg.y_size/ds/2; | 1044 | cy = jpg.y_size/ds/2; |
1078 | 1045 | ||
@@ -1091,24 +1058,10 @@ int load_and_show(char* filename) | |||
1091 | rb->lcd_puts(0, 3, print); | 1058 | rb->lcd_puts(0, 3, print); |
1092 | rb->lcd_update(); | 1059 | rb->lcd_update(); |
1093 | } | 1060 | } |
1061 | |||
1094 | MYLCD(clear_display)(); | 1062 | MYLCD(clear_display)(); |
1095 | #ifdef HAVE_LCD_COLOR | 1063 | draw_image_rect(p_disp, 0, 0, |
1096 | yuv_bitmap_part( | 1064 | p_disp->width-p_disp->x, p_disp->height-p_disp->y); |
1097 | p_disp->bitmap, p_disp->csub_x, p_disp->csub_y, | ||
1098 | p_disp->x, p_disp->y, p_disp->stride, | ||
1099 | MAX(0, (LCD_WIDTH - p_disp->width) / 2), | ||
1100 | MAX(0, (LCD_HEIGHT - p_disp->height) / 2), | ||
1101 | MIN(LCD_WIDTH, p_disp->width), | ||
1102 | MIN(LCD_HEIGHT, p_disp->height), | ||
1103 | jpeg_settings.colour_mode, jpeg_settings.dither_mode); | ||
1104 | #else | ||
1105 | MYXLCD(gray_bitmap_part)( | ||
1106 | p_disp->bitmap[0], p_disp->x, p_disp->y, p_disp->stride, | ||
1107 | MAX(0, (LCD_WIDTH - p_disp->width) / 2), | ||
1108 | MAX(0, (LCD_HEIGHT - p_disp->height) / 2), | ||
1109 | MIN(LCD_WIDTH, p_disp->width), | ||
1110 | MIN(LCD_HEIGHT, p_disp->height)); | ||
1111 | #endif | ||
1112 | MYLCD_UPDATE(); | 1065 | MYLCD_UPDATE(); |
1113 | 1066 | ||
1114 | #ifdef USEGSLIB | 1067 | #ifdef USEGSLIB |
diff --git a/apps/plugins/png/png.c b/apps/plugins/png/png.c index 216077767c..8a5d05be9a 100644 --- a/apps/plugins/png/png.c +++ b/apps/plugins/png/png.c | |||
@@ -1302,7 +1302,7 @@ void LodePNG_decode(LodePNG_Decoder* decoder, unsigned char* in, size_t insize, | |||
1302 | /*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"*/ | 1302 | /*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"*/ |
1303 | if (!(decoder->infoRaw.color.colorType == 2 || decoder->infoRaw.color.colorType == 6) && !(decoder->infoRaw.color.bitDepth == 8)) { decoder->error = 56; return; } | 1303 | if (!(decoder->infoRaw.color.colorType == 2 || decoder->infoRaw.color.colorType == 6) && !(decoder->infoRaw.color.bitDepth == 8)) { decoder->error = 56; return; } |
1304 | converted_image = (fb_data *)((intptr_t)(memory + 3) & ~3); | 1304 | converted_image = (fb_data *)((intptr_t)(memory + 3) & ~3); |
1305 | converted_image_size = FB_DATA_SZ*decoder->infoPng.width*decoder->infoPng.height; | 1305 | converted_image_size = decoder->infoPng.width*decoder->infoPng.height; |
1306 | if ((unsigned char *)(converted_image + converted_image_size) >= decoded_image) { decoder->error = OUT_OF_MEMORY; } | 1306 | if ((unsigned char *)(converted_image + converted_image_size) >= decoded_image) { decoder->error = OUT_OF_MEMORY; } |
1307 | if (!decoder->error) decoder->error = LodePNG_convert(converted_image, decoded_image, &decoder->infoRaw.color, &decoder->infoPng.color, decoder->infoPng.width, decoder->infoPng.height); | 1307 | if (!decoder->error) decoder->error = LodePNG_convert(converted_image, decoded_image, &decoder->infoRaw.color, &decoder->infoPng.color, decoder->infoPng.width, decoder->infoPng.height); |
1308 | } | 1308 | } |
@@ -1534,6 +1534,15 @@ int show_menu(void) /* return 1 to quit */ | |||
1534 | return 0; | 1534 | return 0; |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | void draw_image(struct LodePNG_Decoder* decoder) | ||
1538 | { | ||
1539 | rb->lcd_bitmap_part(resized_image, decoder->x, decoder->y, decoder->infoPng.width/ds /*stride*/, | ||
1540 | MAX(0, (LCD_WIDTH - (int)decoder->infoPng.width/(int)ds) / 2), | ||
1541 | MAX(0, (LCD_HEIGHT - (int)decoder->infoPng.height/(int)ds) / 2), | ||
1542 | decoder->infoPng.width/ds - decoder->x, | ||
1543 | decoder->infoPng.height/ds - decoder->y); | ||
1544 | } | ||
1545 | |||
1537 | /* Pan the viewing window right - move image to the left and fill in | 1546 | /* Pan the viewing window right - move image to the left and fill in |
1538 | the right-hand side */ | 1547 | the right-hand side */ |
1539 | static void pan_view_right(struct LodePNG_Decoder* decoder) | 1548 | static void pan_view_right(struct LodePNG_Decoder* decoder) |
@@ -1541,14 +1550,10 @@ static void pan_view_right(struct LodePNG_Decoder* decoder) | |||
1541 | int move; | 1550 | int move; |
1542 | 1551 | ||
1543 | move = MIN(HSCROLL, decoder->infoPng.width/ds - decoder->x - LCD_WIDTH); | 1552 | move = MIN(HSCROLL, decoder->infoPng.width/ds - decoder->x - LCD_WIDTH); |
1544 | if (move > 0 && decoder->infoPng.width/ds > LCD_WIDTH) | 1553 | if (move > 0) |
1545 | { | 1554 | { |
1546 | decoder->x += move; | 1555 | decoder->x += move; |
1547 | rb->lcd_bitmap_part(resized_image, decoder->x, decoder->y, decoder->infoPng.width/ds /*stride*/, | 1556 | draw_image(decoder); |
1548 | MAX(0, (LCD_WIDTH - (int)decoder->infoPng.width/(int)ds) / 2), | ||
1549 | MAX(0, (LCD_HEIGHT - (int)decoder->infoPng.height/(int)ds) / 2), | ||
1550 | MIN(LCD_WIDTH, decoder->infoPng.width/ds), | ||
1551 | MIN(LCD_HEIGHT, decoder->infoPng.height/ds)); | ||
1552 | rb->lcd_update(); | 1557 | rb->lcd_update(); |
1553 | } | 1558 | } |
1554 | } | 1559 | } |
@@ -1563,11 +1568,7 @@ static void pan_view_left(struct LodePNG_Decoder* decoder) | |||
1563 | if (move > 0) | 1568 | if (move > 0) |
1564 | { | 1569 | { |
1565 | decoder->x -= move; | 1570 | decoder->x -= move; |
1566 | rb->lcd_bitmap_part(resized_image, decoder->x, decoder->y, decoder->infoPng.width/ds /*stride*/, | 1571 | draw_image(decoder); |
1567 | MAX(0, (LCD_WIDTH - (int)decoder->infoPng.width/(int)ds) / 2), | ||
1568 | MAX(0, (LCD_HEIGHT - (int)decoder->infoPng.height/(int)ds) / 2), | ||
1569 | MIN(LCD_WIDTH, decoder->infoPng.width/ds), | ||
1570 | MIN(LCD_HEIGHT, decoder->infoPng.height/ds)); | ||
1571 | rb->lcd_update(); | 1572 | rb->lcd_update(); |
1572 | } | 1573 | } |
1573 | } | 1574 | } |
@@ -1583,11 +1584,7 @@ static void pan_view_up(struct LodePNG_Decoder* decoder) | |||
1583 | if (move > 0) | 1584 | if (move > 0) |
1584 | { | 1585 | { |
1585 | decoder->y -= move; | 1586 | decoder->y -= move; |
1586 | rb->lcd_bitmap_part(resized_image, decoder->x, decoder->y, decoder->infoPng.width/ds /*stride*/, | 1587 | draw_image(decoder); |
1587 | MAX(0, (LCD_WIDTH - (int)decoder->infoPng.width/(int)ds) / 2), | ||
1588 | MAX(0, (LCD_HEIGHT - (int)decoder->infoPng.height/(int)ds) / 2), | ||
1589 | MIN(LCD_WIDTH, decoder->infoPng.width/ds), | ||
1590 | MIN(LCD_HEIGHT, decoder->infoPng.height/ds)); | ||
1591 | rb->lcd_update(); | 1588 | rb->lcd_update(); |
1592 | } | 1589 | } |
1593 | } | 1590 | } |
@@ -1599,14 +1596,10 @@ static void pan_view_down(struct LodePNG_Decoder* decoder) | |||
1599 | int move; | 1596 | int move; |
1600 | 1597 | ||
1601 | move = MIN(VSCROLL, decoder->infoPng.height/ds - decoder->y - LCD_HEIGHT); | 1598 | move = MIN(VSCROLL, decoder->infoPng.height/ds - decoder->y - LCD_HEIGHT); |
1602 | if (move > 0 && decoder->infoPng.height/ds > LCD_HEIGHT) | 1599 | if (move > 0) |
1603 | { | 1600 | { |
1604 | decoder->y += move; | 1601 | decoder->y += move; |
1605 | rb->lcd_bitmap_part(resized_image, decoder->x, decoder->y, decoder->infoPng.width/ds /*stride*/, | 1602 | draw_image(decoder); |
1606 | MAX(0, (LCD_WIDTH - (int)decoder->infoPng.width/(int)ds) / 2), | ||
1607 | MAX(0, (LCD_HEIGHT - (int)decoder->infoPng.height/(int)ds) / 2), | ||
1608 | MIN(LCD_WIDTH, decoder->infoPng.width/ds), | ||
1609 | MIN(LCD_HEIGHT, decoder->infoPng.height/ds)); | ||
1610 | rb->lcd_update(); | 1603 | rb->lcd_update(); |
1611 | } | 1604 | } |
1612 | } | 1605 | } |
@@ -1765,7 +1758,7 @@ void cb_progress(int current, int total) | |||
1765 | 1758 | ||
1766 | int pngmem(struct LodePNG_Decoder* decoder, int ds) | 1759 | int pngmem(struct LodePNG_Decoder* decoder, int ds) |
1767 | { | 1760 | { |
1768 | return decoder->infoPng.width * decoder->infoPng.height * FB_DATA_SZ / ds; | 1761 | return (decoder->infoPng.width/ds) * (decoder->infoPng.height/ds) * FB_DATA_SZ; |
1769 | } | 1762 | } |
1770 | 1763 | ||
1771 | /* how far can we zoom in without running out of memory */ | 1764 | /* how far can we zoom in without running out of memory */ |
@@ -1819,7 +1812,7 @@ fb_data *get_image(struct LodePNG_Decoder* decoder) | |||
1819 | previous_size = converted_image_size; | 1812 | previous_size = converted_image_size; |
1820 | } | 1813 | } |
1821 | 1814 | ||
1822 | size[ds] = decoder->infoPng.width * decoder->infoPng.height * FB_DATA_SZ / ds; | 1815 | size[ds] = (decoder->infoPng.width/ds) * (decoder->infoPng.height/ds); |
1823 | 1816 | ||
1824 | /* assign image buffer */ | 1817 | /* assign image buffer */ |
1825 | if (ds > 1) { | 1818 | if (ds > 1) { |
@@ -1837,7 +1830,7 @@ fb_data *get_image(struct LodePNG_Decoder* decoder) | |||
1837 | if ((unsigned char *)(disp[ds] + size[ds]) >= memory_max) { | 1830 | if ((unsigned char *)(disp[ds] + size[ds]) >= memory_max) { |
1838 | //rb->splash(HZ, "Out of Memory"); | 1831 | //rb->splash(HZ, "Out of Memory"); |
1839 | // Still display the original image which is already decoded in RAM | 1832 | // Still display the original image which is already decoded in RAM |
1840 | disp[ds] = NULL; | 1833 | disp[ds] = converted_image; |
1841 | ds = 1; | 1834 | ds = 1; |
1842 | return converted_image; | 1835 | return converted_image; |
1843 | } else { | 1836 | } else { |
@@ -1858,10 +1851,9 @@ fb_data *get_image(struct LodePNG_Decoder* decoder) | |||
1858 | } | 1851 | } |
1859 | } else { | 1852 | } else { |
1860 | disp[ds] = converted_image; | 1853 | disp[ds] = converted_image; |
1854 | return converted_image; | ||
1861 | } | 1855 | } |
1862 | 1856 | ||
1863 | |||
1864 | |||
1865 | previous_disp = disp[ds]; | 1857 | previous_disp = disp[ds]; |
1866 | previous_size = size[ds]; | 1858 | previous_size = size[ds]; |
1867 | 1859 | ||
@@ -1958,6 +1950,7 @@ int load_and_show(char* filename) | |||
1958 | rb->lcd_puts(0, 2, print); | 1950 | rb->lcd_puts(0, 2, print); |
1959 | rb->lcd_update(); | 1951 | rb->lcd_update(); |
1960 | } | 1952 | } |
1953 | |||
1961 | ds_max = max_downscale(&decoder); /* check display constraint */ | 1954 | ds_max = max_downscale(&decoder); /* check display constraint */ |
1962 | 1955 | ||
1963 | ds = ds_max; /* initials setting */ | 1956 | ds = ds_max; /* initials setting */ |
@@ -2009,7 +2002,6 @@ int load_and_show(char* filename) | |||
2009 | rb->lcd_update(); | 2002 | rb->lcd_update(); |
2010 | } | 2003 | } |
2011 | 2004 | ||
2012 | do { | ||
2013 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 2005 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM |
2014 | if (plug_buf && (decoder.error == FILE_TOO_LARGE || decoder.error == OUT_OF_MEMORY || decoder.error == Z_MEM_ERROR)) | 2006 | if (plug_buf && (decoder.error == FILE_TOO_LARGE || decoder.error == OUT_OF_MEMORY || decoder.error == Z_MEM_ERROR)) |
2015 | { | 2007 | { |
@@ -2073,9 +2065,6 @@ int load_and_show(char* filename) | |||
2073 | //else | 2065 | //else |
2074 | #endif | 2066 | #endif |
2075 | 2067 | ||
2076 | if (!decoder.error) { | ||
2077 | resized_image = get_image(&decoder); /* decode or fetch from cache */ | ||
2078 | } | ||
2079 | if (decoder.error) { | 2068 | if (decoder.error) { |
2080 | 2069 | ||
2081 | switch (decoder.error) { | 2070 | switch (decoder.error) { |
@@ -2152,11 +2141,14 @@ int load_and_show(char* filename) | |||
2152 | } else if (decoder.error == OUT_OF_MEMORY && entries == 1) { | 2141 | } else if (decoder.error == OUT_OF_MEMORY && entries == 1) { |
2153 | return PLUGIN_ERROR; | 2142 | return PLUGIN_ERROR; |
2154 | } else { | 2143 | } else { |
2144 | file_pt[curfile] = '\0'; | ||
2155 | return change_filename(direction); | 2145 | return change_filename(direction); |
2156 | } | 2146 | } |
2157 | |||
2158 | } | 2147 | } |
2159 | 2148 | ||
2149 | do { | ||
2150 | resized_image = get_image(&decoder); /* decode or fetch from cache */ | ||
2151 | |||
2160 | cx = decoder.infoPng.width/ds/2; /* center the view */ | 2152 | cx = decoder.infoPng.width/ds/2; /* center the view */ |
2161 | cy = decoder.infoPng.height/ds/2; | 2153 | cy = decoder.infoPng.height/ds/2; |
2162 | 2154 | ||
@@ -2171,18 +2163,9 @@ int load_and_show(char* filename) | |||
2171 | } | 2163 | } |
2172 | 2164 | ||
2173 | rb->lcd_clear_display(); | 2165 | rb->lcd_clear_display(); |
2174 | 2166 | draw_image(&decoder); | |
2175 | rb->lcd_bitmap_part(resized_image, decoder.x, decoder.y, decoder.infoPng.width/ds /*stride*/, | ||
2176 | MAX(0, (LCD_WIDTH - (int)decoder.infoPng.width/(int)ds) / 2), | ||
2177 | MAX(0, (LCD_HEIGHT - (int)decoder.infoPng.height/(int)ds) / 2), | ||
2178 | MIN(LCD_WIDTH, decoder.infoPng.width/ds), | ||
2179 | MIN(LCD_HEIGHT, decoder.infoPng.height/ds)); | ||
2180 | |||
2181 | rb->lcd_update(); | 2167 | rb->lcd_update(); |
2182 | 2168 | ||
2183 | //} | ||
2184 | //} | ||
2185 | |||
2186 | /* drawing is now finished, play around with scrolling | 2169 | /* drawing is now finished, play around with scrolling |
2187 | * until you press OFF or connect USB | 2170 | * until you press OFF or connect USB |
2188 | */ | 2171 | */ |