summaryrefslogtreecommitdiff
path: root/apps/plugins/imageviewer/jpeg/jpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/imageviewer/jpeg/jpeg.c')
-rw-r--r--apps/plugins/imageviewer/jpeg/jpeg.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/apps/plugins/imageviewer/jpeg/jpeg.c b/apps/plugins/imageviewer/jpeg/jpeg.c
index 5f69cc7f51..511a7054e1 100644
--- a/apps/plugins/imageviewer/jpeg/jpeg.c
+++ b/apps/plugins/imageviewer/jpeg/jpeg.c
@@ -69,20 +69,8 @@ static struct jpeg jpg; /* too large for stack */
69 69
70/************************* Implementation ***************************/ 70/************************* Implementation ***************************/
71 71
72bool img_ext(const char *ext) 72static void draw_image_rect(struct image_info *info,
73{ 73 int x, int y, int width, int height)
74 if(!ext)
75 return false;
76 if(!rb->strcasecmp(ext,".jpg") ||
77 !rb->strcasecmp(ext,".jpe") ||
78 !rb->strcasecmp(ext,".jpeg"))
79 return true;
80 else
81 return false;
82}
83
84void draw_image_rect(struct image_info *info,
85 int x, int y, int width, int height)
86{ 74{
87 struct t_disp* pdisp = (struct t_disp*)info->data; 75 struct t_disp* pdisp = (struct t_disp*)info->data;
88#ifdef HAVE_LCD_COLOR 76#ifdef HAVE_LCD_COLOR
@@ -92,7 +80,7 @@ void draw_image_rect(struct image_info *info,
92 x + MAX(0, (LCD_WIDTH - info->width) / 2), 80 x + MAX(0, (LCD_WIDTH - info->width) / 2),
93 y + MAX(0, (LCD_HEIGHT - info->height) / 2), 81 y + MAX(0, (LCD_HEIGHT - info->height) / 2),
94 width, height, 82 width, height,
95 settings.jpeg_colour_mode, settings.jpeg_dither_mode); 83 iv->settings->jpeg_colour_mode, iv->settings->jpeg_dither_mode);
96#else 84#else
97 mylcd_ub_gray_bitmap_part( 85 mylcd_ub_gray_bitmap_part(
98 pdisp->bitmap[0], info->x + x, info->y + y, pdisp->stride, 86 pdisp->bitmap[0], info->x + x, info->y + y, pdisp->stride,
@@ -102,7 +90,7 @@ void draw_image_rect(struct image_info *info,
102#endif 90#endif
103} 91}
104 92
105int img_mem(int ds) 93static int img_mem(int ds)
106{ 94{
107 int size; 95 int size;
108 struct jpeg *p_jpg = &jpg; 96 struct jpeg *p_jpg = &jpg;
@@ -121,8 +109,8 @@ int img_mem(int ds)
121 return size; 109 return size;
122} 110}
123 111
124int load_image(char *filename, struct image_info *info, 112static int load_image(char *filename, struct image_info *info,
125 unsigned char *buf, ssize_t *buf_size) 113 unsigned char *buf, ssize_t *buf_size)
126{ 114{
127 int fd; 115 int fd;
128 int filesize; 116 int filesize;
@@ -154,7 +142,7 @@ int load_image(char *filename, struct image_info *info,
154 return PLUGIN_OUTOFMEM; 142 return PLUGIN_OUTOFMEM;
155 } 143 }
156 144
157 if(!running_slideshow) 145 if(!iv->running_slideshow)
158 { 146 {
159 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); 147 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1);
160 rb->lcd_putsf(0, 1, "loading %d bytes", filesize); 148 rb->lcd_putsf(0, 1, "loading %d bytes", filesize);
@@ -164,13 +152,13 @@ int load_image(char *filename, struct image_info *info,
164 rb->read(fd, buf_jpeg, filesize); 152 rb->read(fd, buf_jpeg, filesize);
165 rb->close(fd); 153 rb->close(fd);
166 154
167 if(!running_slideshow) 155 if(!iv->running_slideshow)
168 { 156 {
169 rb->lcd_puts(0, 2, "decoding markers"); 157 rb->lcd_puts(0, 2, "decoding markers");
170 rb->lcd_update(); 158 rb->lcd_update();
171 } 159 }
172#ifdef DISK_SPINDOWN 160#ifdef DISK_SPINDOWN
173 else if(immediate_ata_off) 161 else if(iv->immediate_ata_off)
174 { 162 {
175 /* running slideshow and time is long enough: power down disk */ 163 /* running slideshow and time is long enough: power down disk */
176 rb->storage_sleep(); 164 rb->storage_sleep();
@@ -190,7 +178,7 @@ int load_image(char *filename, struct image_info *info,
190 default_huff_tbl(p_jpg); /* use default */ 178 default_huff_tbl(p_jpg); /* use default */
191 build_lut(p_jpg); /* derive Huffman and other lookup-tables */ 179 build_lut(p_jpg); /* derive Huffman and other lookup-tables */
192 180
193 if(!running_slideshow) 181 if(!iv->running_slideshow)
194 { 182 {
195 rb->lcd_putsf(0, 2, "image %dx%d", p_jpg->x_size, p_jpg->y_size); 183 rb->lcd_putsf(0, 2, "image %dx%d", p_jpg->x_size, p_jpg->y_size);
196 rb->lcd_update(); 184 rb->lcd_update();
@@ -202,7 +190,7 @@ int load_image(char *filename, struct image_info *info,
202 return PLUGIN_OK; 190 return PLUGIN_OK;
203} 191}
204 192
205int get_image(struct image_info *info, int ds) 193static int get_image(struct image_info *info, int ds)
206{ 194{
207 int w, h; /* used to center output */ 195 int w, h; /* used to center output */
208 int size; /* decompressed image size */ 196 int size; /* decompressed image size */
@@ -262,7 +250,7 @@ int get_image(struct image_info *info, int ds)
262 buf_images += size; 250 buf_images += size;
263 buf_images_size -= size; 251 buf_images_size -= size;
264 252
265 if(!running_slideshow) 253 if(!iv->running_slideshow)
266 { 254 {
267 rb->lcd_putsf(0, 3, "decoding %d*%d", info->width, info->height); 255 rb->lcd_putsf(0, 3, "decoding %d*%d", info->width, info->height);
268 rb->lcd_update(); 256 rb->lcd_update();
@@ -275,10 +263,10 @@ int get_image(struct image_info *info, int ds)
275 time = *rb->current_tick; 263 time = *rb->current_tick;
276#ifdef HAVE_ADJUSTABLE_CPU_FREQ 264#ifdef HAVE_ADJUSTABLE_CPU_FREQ
277 rb->cpu_boost(true); 265 rb->cpu_boost(true);
278 status = jpeg_decode(p_jpg, p_disp->bitmap, ds, cb_progress); 266 status = jpeg_decode(p_jpg, p_disp->bitmap, ds, iv->cb_progress);
279 rb->cpu_boost(false); 267 rb->cpu_boost(false);
280#else 268#else
281 status = jpeg_decode(p_jpg, p_disp->bitmap, ds, cb_progress); 269 status = jpeg_decode(p_jpg, p_disp->bitmap, ds, iv->cb_progress);
282#endif 270#endif
283 if (status) 271 if (status)
284 { 272 {
@@ -287,7 +275,7 @@ int get_image(struct image_info *info, int ds)
287 } 275 }
288 time = *rb->current_tick - time; 276 time = *rb->current_tick - time;
289 277
290 if(!running_slideshow) 278 if(!iv->running_slideshow)
291 { 279 {
292 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); 280 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ);
293 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ 281 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */
@@ -297,3 +285,13 @@ int get_image(struct image_info *info, int ds)
297 285
298 return PLUGIN_OK; 286 return PLUGIN_OK;
299} 287}
288
289const struct image_decoder image_decoder = {
290 false,
291 img_mem,
292 load_image,
293 get_image,
294 draw_image_rect,
295};
296
297IMGDEC_HEADER