summaryrefslogtreecommitdiff
path: root/apps/plugins/imageviewer/bmp/bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/imageviewer/bmp/bmp.c')
-rw-r--r--apps/plugins/imageviewer/bmp/bmp.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/apps/plugins/imageviewer/bmp/bmp.c b/apps/plugins/imageviewer/bmp/bmp.c
index 6d33575f98..b7efbb7e2c 100644
--- a/apps/plugins/imageviewer/bmp/bmp.c
+++ b/apps/plugins/imageviewer/bmp/bmp.c
@@ -65,18 +65,13 @@ struct bitmap bmp;
65 65
66/************************* Implementation ***************************/ 66/************************* Implementation ***************************/
67 67
68bool img_ext(const char *ext) 68#if defined(USEGSLIB) && (CONFIG_PLATFORM & PLATFORM_HOSTED)
69{ 69/* hack: fix error "undefined reference to `_grey_info'". */
70 if (!ext) 70GREY_INFO_STRUCT
71 return false; 71#endif /* USEGSLIB */
72 if (!rb->strcasecmp(ext,".bmp"))
73 return true;
74 else
75 return false;
76}
77 72
78void draw_image_rect(struct image_info *info, 73static void draw_image_rect(struct image_info *info,
79 int x, int y, int width, int height) 74 int x, int y, int width, int height)
80{ 75{
81 struct t_disp* pdisp = (struct t_disp*)info->data; 76 struct t_disp* pdisp = (struct t_disp*)info->data;
82#ifdef HAVE_LCD_COLOR 77#ifdef HAVE_LCD_COLOR
@@ -95,7 +90,7 @@ void draw_image_rect(struct image_info *info,
95#endif 90#endif
96} 91}
97 92
98int img_mem(int ds) 93static int img_mem(int ds)
99{ 94{
100#ifndef USEGSLIB 95#ifndef USEGSLIB
101 return (bmp.width/ds) * (bmp.height/ds) * sizeof (fb_data); 96 return (bmp.width/ds) * (bmp.height/ds) * sizeof (fb_data);
@@ -104,8 +99,8 @@ int img_mem(int ds)
104#endif 99#endif
105} 100}
106 101
107int load_image(char *filename, struct image_info *info, 102static int load_image(char *filename, struct image_info *info,
108 unsigned char *buf, ssize_t *buf_size) 103 unsigned char *buf, ssize_t *buf_size)
109{ 104{
110 int w, h; /* used to center output */ 105 int w, h; /* used to center output */
111 long time; /* measured ticks */ 106 long time; /* measured ticks */
@@ -147,7 +142,7 @@ int load_image(char *filename, struct image_info *info,
147 } 142 }
148#endif 143#endif
149#ifdef USE_PLUG_BUF 144#ifdef USE_PLUG_BUF
150 if (!plug_buf) 145 if (!iv->plug_buf)
151#endif 146#endif
152 { 147 {
153 while (size > *buf_size && bmp.width >= 2 && bmp.height >= 2 && ds < 8) 148 while (size > *buf_size && bmp.width >= 2 && bmp.height >= 2 && ds < 8)
@@ -174,7 +169,7 @@ int load_image(char *filename, struct image_info *info,
174 return PLUGIN_OUTOFMEM; 169 return PLUGIN_OUTOFMEM;
175 } 170 }
176 171
177 if (!running_slideshow) 172 if (!iv->running_slideshow)
178 { 173 {
179 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); 174 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1);
180 rb->lcd_putsf(0, 1, "loading %dx%d%s", 175 rb->lcd_putsf(0, 1, "loading %dx%d%s",
@@ -204,7 +199,7 @@ int load_image(char *filename, struct image_info *info,
204 return PLUGIN_ERROR; 199 return PLUGIN_ERROR;
205 } 200 }
206 201
207 if (!running_slideshow) 202 if (!iv->running_slideshow)
208 { 203 {
209 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); 204 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ);
210 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ 205 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */
@@ -212,7 +207,7 @@ int load_image(char *filename, struct image_info *info,
212 rb->lcd_update(); 207 rb->lcd_update();
213 } 208 }
214#ifdef DISK_SPINDOWN 209#ifdef DISK_SPINDOWN
215 else if (immediate_ata_off) 210 else if(iv->immediate_ata_off)
216 { 211 {
217 /* running slideshow and time is long enough: power down disk */ 212 /* running slideshow and time is long enough: power down disk */
218 rb->storage_sleep(); 213 rb->storage_sleep();
@@ -223,7 +218,7 @@ int load_image(char *filename, struct image_info *info,
223 buf_images = buf_root = buf + size; 218 buf_images = buf_root = buf + size;
224 buf_images_size = root_size = *buf_size - size; 219 buf_images_size = root_size = *buf_size - size;
225 220
226 if (!running_slideshow) 221 if (!iv->running_slideshow)
227 { 222 {
228 rb->lcd_putsf(0, 2, "image %dx%d", bmp.width, bmp.height); 223 rb->lcd_putsf(0, 2, "image %dx%d", bmp.width, bmp.height);
229 rb->lcd_update(); 224 rb->lcd_update();
@@ -235,7 +230,7 @@ int load_image(char *filename, struct image_info *info,
235 return PLUGIN_OK; 230 return PLUGIN_OK;
236} 231}
237 232
238int get_image(struct image_info *info, int ds) 233static int get_image(struct image_info *info, int ds)
239{ 234{
240 struct t_disp* p_disp = &disp[ds]; /* short cut */ 235 struct t_disp* p_disp = &disp[ds]; /* short cut */
241 236
@@ -270,7 +265,7 @@ int get_image(struct image_info *info, int ds)
270 buf_images += size; 265 buf_images += size;
271 buf_images_size -= size; 266 buf_images_size -= size;
272 267
273 if (!running_slideshow) 268 if (!iv->running_slideshow)
274 { 269 {
275 rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); 270 rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height);
276 rb->lcd_update(); 271 rb->lcd_update();
@@ -294,3 +289,13 @@ int get_image(struct image_info *info, int ds)
294 289
295 return PLUGIN_OK; 290 return PLUGIN_OK;
296} 291}
292
293const struct image_decoder image_decoder = {
294 true,
295 img_mem,
296 load_image,
297 get_image,
298 draw_image_rect,
299};
300
301IMGDEC_HEADER