summaryrefslogtreecommitdiff
path: root/apps/plugins/imageviewer/png/png.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/imageviewer/png/png.c')
-rw-r--r--apps/plugins/imageviewer/png/png.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c
index 29b6713585..34a8a1fd34 100644
--- a/apps/plugins/imageviewer/png/png.c
+++ b/apps/plugins/imageviewer/png/png.c
@@ -89,7 +89,8 @@ static int img_mem(int ds)
89} 89}
90 90
91static int load_image(char *filename, struct image_info *info, 91static int load_image(char *filename, struct image_info *info,
92 unsigned char *buf, ssize_t *buf_size) 92 unsigned char *buf, ssize_t *buf_size,
93 int offset, int file_size)
93{ 94{
94 int fd; 95 int fd;
95 long time = 0; /* measured ticks */ 96 long time = 0; /* measured ticks */
@@ -97,7 +98,7 @@ static int load_image(char *filename, struct image_info *info,
97 LodePNG_Decoder *p_decoder = &decoder; 98 LodePNG_Decoder *p_decoder = &decoder;
98 99
99 unsigned char *memory, *memory_max, *image; 100 unsigned char *memory, *memory_max, *image;
100 size_t memory_size, file_size; 101 size_t memory_size;
101 102
102 /* cleanup */ 103 /* cleanup */
103 memset(&disp, 0, sizeof(disp)); 104 memset(&disp, 0, sizeof(disp));
@@ -113,7 +114,15 @@ static int load_image(char *filename, struct image_info *info,
113 rb->splashf(HZ, "err opening %s: %d", filename, fd); 114 rb->splashf(HZ, "err opening %s: %d", filename, fd);
114 return PLUGIN_ERROR; 115 return PLUGIN_ERROR;
115 } 116 }
116 file_size = rb->filesize(fd); 117
118 if (offset)
119 {
120 rb->lseek(fd, offset, SEEK_SET);
121 }
122 else
123 {
124 file_size = rb->filesize(fd);
125 }
117 126
118 DEBUGF("reading file '%s'\n", filename); 127 DEBUGF("reading file '%s'\n", filename);
119 128
@@ -122,7 +131,7 @@ static int load_image(char *filename, struct image_info *info,
122 rb->lcd_update(); 131 rb->lcd_update();
123 } 132 }
124 133
125 if (file_size > memory_size) { 134 if ((size_t)file_size > memory_size) {
126 p_decoder->error = FILE_TOO_LARGE; 135 p_decoder->error = FILE_TOO_LARGE;
127 rb->close(fd); 136 rb->close(fd);
128 137