diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-11-21 13:47:56 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-11-21 13:47:56 +0000 |
commit | e5b1a7d4237a9006b6c49c9c1c13b292ca4ecf7c (patch) | |
tree | f0b9dd1cba0a4ee70afd8b6da64a05286f76c380 /apps/plugins/imageviewer/bmp | |
parent | eef21cb18ae4bc7cdf83830554a848e0c733a73d (diff) | |
download | rockbox-e5b1a7d4237a9006b6c49c9c1c13b292ca4ecf7c.tar.gz rockbox-e5b1a7d4237a9006b6c49c9c1c13b292ca4ecf7c.zip |
FS#6321: Universal Image Viewer
This unifies jpeg viewer, png viewer, and bmp viewer to one plugin, image viewer, so that you can navigate through different image formats.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28626 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/imageviewer/bmp')
-rw-r--r-- | apps/plugins/imageviewer/bmp/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/imageviewer/bmp/bmp.c | 47 | ||||
-rw-r--r-- | apps/plugins/imageviewer/bmp/bmp.make | 14 | ||||
-rw-r--r-- | apps/plugins/imageviewer/bmp/bmp_ui.c | 5 |
4 files changed, 36 insertions, 31 deletions
diff --git a/apps/plugins/imageviewer/bmp/SOURCES b/apps/plugins/imageviewer/bmp/SOURCES index a50d245846..29297c9ec2 100644 --- a/apps/plugins/imageviewer/bmp/SOURCES +++ b/apps/plugins/imageviewer/bmp/SOURCES | |||
@@ -1,2 +1 @@ | |||
1 | bmp_ui.c | ||
2 | bmp.c | bmp.c | |
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 | ||
68 | bool 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) | 70 | GREY_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 | ||
78 | void draw_image_rect(struct image_info *info, | 73 | static 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 | ||
98 | int img_mem(int ds) | 93 | static 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 | ||
107 | int load_image(char *filename, struct image_info *info, | 102 | static 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 | ||
238 | int get_image(struct image_info *info, int ds) | 233 | static 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 | |||
293 | const struct image_decoder image_decoder = { | ||
294 | true, | ||
295 | img_mem, | ||
296 | load_image, | ||
297 | get_image, | ||
298 | draw_image_rect, | ||
299 | }; | ||
300 | |||
301 | IMGDEC_HEADER | ||
diff --git a/apps/plugins/imageviewer/bmp/bmp.make b/apps/plugins/imageviewer/bmp/bmp.make index 0582ba3eb3..0947dd6166 100644 --- a/apps/plugins/imageviewer/bmp/bmp.make +++ b/apps/plugins/imageviewer/bmp/bmp.make | |||
@@ -10,12 +10,18 @@ | |||
10 | BMPSRCDIR := $(IMGVSRCDIR)/bmp | 10 | BMPSRCDIR := $(IMGVSRCDIR)/bmp |
11 | BMPBUILDDIR := $(IMGVBUILDDIR)/bmp | 11 | BMPBUILDDIR := $(IMGVBUILDDIR)/bmp |
12 | 12 | ||
13 | ROCKS += $(BMPBUILDDIR)/bmp.rock | ||
14 | |||
15 | BMP_SRC := $(call preprocess, $(BMPSRCDIR)/SOURCES) | 13 | BMP_SRC := $(call preprocess, $(BMPSRCDIR)/SOURCES) |
16 | BMP_OBJ := $(call c2obj, $(BMP_SRC)) | 14 | BMP_OBJ := $(call c2obj, $(BMP_SRC)) |
17 | 15 | ||
18 | # add source files to OTHER_SRC to get automatic dependencies | ||
19 | OTHER_SRC += $(BMP_SRC) | 16 | OTHER_SRC += $(BMP_SRC) |
20 | 17 | ||
21 | $(BMPBUILDDIR)/bmp.rock: $(BMP_OBJ) | 18 | ROCKS += $(BMPBUILDDIR)/bmp.ovl |
19 | |||
20 | $(BMPBUILDDIR)/bmp.refmap: $(BMP_OBJ) | ||
21 | $(BMPBUILDDIR)/bmp.link: $(PLUGIN_LDS) $(BMPBUILDDIR)/bmp.refmap | ||
22 | $(BMPBUILDDIR)/bmp.ovl: $(BMP_OBJ) | ||
23 | |||
24 | # special pattern rule for compiling image decoder with extra flags | ||
25 | $(BMPBUILDDIR)/%.o: $(BMPSRCDIR)/%.c $(BMPSRCDIR)/bmp.make | ||
26 | $(SILENT)mkdir -p $(dir $@) | ||
27 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(IMGDECFLAGS) -c $< -o $@ | ||
diff --git a/apps/plugins/imageviewer/bmp/bmp_ui.c b/apps/plugins/imageviewer/bmp/bmp_ui.c deleted file mode 100644 index 8ff3e0c880..0000000000 --- a/apps/plugins/imageviewer/bmp/bmp_ui.c +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #define BMP_VIEWER | ||
2 | #define MENU_TITLE "BMP Menu" | ||
3 | #define UNSCALED_IS_AVAILABLE 1 | ||
4 | |||
5 | #include "../imageviewer.c" | ||