summaryrefslogtreecommitdiff
path: root/apps/plugins/imageviewer/png
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/imageviewer/png')
-rw-r--r--apps/plugins/imageviewer/png/SOURCES1
-rw-r--r--apps/plugins/imageviewer/png/png.c55
-rw-r--r--apps/plugins/imageviewer/png/png.make13
-rw-r--r--apps/plugins/imageviewer/png/png_ui.c5
4 files changed, 37 insertions, 37 deletions
diff --git a/apps/plugins/imageviewer/png/SOURCES b/apps/plugins/imageviewer/png/SOURCES
index 8c278b02b9..978150db78 100644
--- a/apps/plugins/imageviewer/png/SOURCES
+++ b/apps/plugins/imageviewer/png/SOURCES
@@ -3,4 +3,3 @@ tinflate.c
3tinfzlib.c 3tinfzlib.c
4png_decoder.c 4png_decoder.c
5png.c 5png.c
6png_ui.c
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c
index 956cad37d8..10404b7c30 100644
--- a/apps/plugins/imageviewer/png/png.c
+++ b/apps/plugins/imageviewer/png/png.c
@@ -50,18 +50,13 @@ static unsigned char *disp_buf;
50#define resize_bitmap grey_resize_bitmap 50#define resize_bitmap grey_resize_bitmap
51#endif 51#endif
52 52
53bool img_ext(const char *ext) 53#if defined(USEGSLIB) && (CONFIG_PLATFORM & PLATFORM_HOSTED)
54{ 54/* hack: fix error "undefined reference to `_grey_info'". */
55 if (!ext) 55GREY_INFO_STRUCT
56 return false; 56#endif /* USEGSLIB */
57 if (!rb->strcasecmp(ext,".png"))
58 return true;
59 else
60 return false;
61}
62 57
63void draw_image_rect(struct image_info *info, 58static void draw_image_rect(struct image_info *info,
64 int x, int y, int width, int height) 59 int x, int y, int width, int height)
65{ 60{
66 unsigned char **pdisp = (unsigned char **)info->data; 61 unsigned char **pdisp = (unsigned char **)info->data;
67 62
@@ -80,7 +75,7 @@ void draw_image_rect(struct image_info *info,
80#endif 75#endif
81} 76}
82 77
83int img_mem(int ds) 78static int img_mem(int ds)
84{ 79{
85 LodePNG_Decoder *p_decoder = &decoder; 80 LodePNG_Decoder *p_decoder = &decoder;
86 81
@@ -93,8 +88,8 @@ int img_mem(int ds)
93#endif 88#endif
94} 89}
95 90
96int load_image(char *filename, struct image_info *info, 91static int load_image(char *filename, struct image_info *info,
97 unsigned char *buf, ssize_t *buf_size) 92 unsigned char *buf, ssize_t *buf_size)
98{ 93{
99 int fd; 94 int fd;
100 long time = 0; /* measured ticks */ 95 long time = 0; /* measured ticks */
@@ -122,7 +117,7 @@ int load_image(char *filename, struct image_info *info,
122 117
123 DEBUGF("reading file '%s'\n", filename); 118 DEBUGF("reading file '%s'\n", filename);
124 119
125 if (!running_slideshow) { 120 if (!iv->running_slideshow) {
126 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1); 121 rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1);
127 rb->lcd_update(); 122 rb->lcd_update();
128 } 123 }
@@ -132,7 +127,7 @@ int load_image(char *filename, struct image_info *info,
132 rb->close(fd); 127 rb->close(fd);
133 128
134 } else { 129 } else {
135 if (!running_slideshow) { 130 if (!iv->running_slideshow) {
136 rb->lcd_putsf(0, 1, "loading %zu bytes", file_size); 131 rb->lcd_putsf(0, 1, "loading %zu bytes", file_size);
137 rb->lcd_update(); 132 rb->lcd_update();
138 } 133 }
@@ -142,12 +137,12 @@ int load_image(char *filename, struct image_info *info,
142 rb->read(fd, image, file_size); 137 rb->read(fd, image, file_size);
143 rb->close(fd); 138 rb->close(fd);
144 139
145 if (!running_slideshow) { 140 if (!iv->running_slideshow) {
146 rb->lcd_puts(0, 2, "decoding image"); 141 rb->lcd_puts(0, 2, "decoding image");
147 rb->lcd_update(); 142 rb->lcd_update();
148 } 143 }
149#ifdef DISK_SPINDOWN 144#ifdef DISK_SPINDOWN
150 else if (immediate_ata_off) { 145 else if (iv->immediate_ata_off) {
151 /* running slideshow and time is long enough: power down disk */ 146 /* running slideshow and time is long enough: power down disk */
152 rb->storage_sleep(); 147 rb->storage_sleep();
153 } 148 }
@@ -167,7 +162,7 @@ int load_image(char *filename, struct image_info *info,
167 162
168 if (!p_decoder->error) { 163 if (!p_decoder->error) {
169 164
170 if (!running_slideshow) { 165 if (!iv->running_slideshow) {
171 rb->lcd_putsf(0, 2, "image %dx%d", 166 rb->lcd_putsf(0, 2, "image %dx%d",
172 p_decoder->infoPng.width, 167 p_decoder->infoPng.width,
173 p_decoder->infoPng.height); 168 p_decoder->infoPng.height);
@@ -181,16 +176,16 @@ int load_image(char *filename, struct image_info *info,
181 time = *rb->current_tick; 176 time = *rb->current_tick;
182#ifdef HAVE_ADJUSTABLE_CPU_FREQ 177#ifdef HAVE_ADJUSTABLE_CPU_FREQ
183 rb->cpu_boost(true); 178 rb->cpu_boost(true);
184 LodePNG_decode(p_decoder, image, file_size, cb_progress); 179 LodePNG_decode(p_decoder, image, file_size, iv->cb_progress);
185 rb->cpu_boost(false); 180 rb->cpu_boost(false);
186#else 181#else
187 LodePNG_decode(p_decoder, image, file_size, cb_progress); 182 LodePNG_decode(p_decoder, image, file_size, iv->cb_progress);
188#endif /*HAVE_ADJUSTABLE_CPU_FREQ*/ 183#endif /*HAVE_ADJUSTABLE_CPU_FREQ*/
189 time = *rb->current_tick - time; 184 time = *rb->current_tick - time;
190 } 185 }
191 } 186 }
192 187
193 if (!running_slideshow && !p_decoder->error) 188 if (!iv->running_slideshow && !p_decoder->error)
194 { 189 {
195 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); 190 rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ);
196 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ 191 rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */
@@ -200,7 +195,7 @@ int load_image(char *filename, struct image_info *info,
200 195
201 if (p_decoder->error) { 196 if (p_decoder->error) {
202#ifdef USE_PLUG_BUF 197#ifdef USE_PLUG_BUF
203 if (plug_buf && (p_decoder->error == FILE_TOO_LARGE || 198 if (iv->plug_buf && (p_decoder->error == FILE_TOO_LARGE ||
204 p_decoder->error == OUT_OF_MEMORY || 199 p_decoder->error == OUT_OF_MEMORY ||
205 p_decoder->error == TINF_DATA_ERROR)) 200 p_decoder->error == TINF_DATA_ERROR))
206 return PLUGIN_OUTOFMEM; 201 return PLUGIN_OUTOFMEM;
@@ -244,7 +239,7 @@ int load_image(char *filename, struct image_info *info,
244 return PLUGIN_OK; 239 return PLUGIN_OK;
245} 240}
246 241
247int get_image(struct image_info *info, int ds) 242static int get_image(struct image_info *info, int ds)
248{ 243{
249 unsigned char **p_disp = &disp[ds]; /* short cut */ 244 unsigned char **p_disp = &disp[ds]; /* short cut */
250 LodePNG_Decoder *p_decoder = &decoder; 245 LodePNG_Decoder *p_decoder = &decoder;
@@ -261,7 +256,7 @@ int get_image(struct image_info *info, int ds)
261 256
262 /* assign image buffer */ 257 /* assign image buffer */
263 if (ds > 1) { 258 if (ds > 1) {
264 if (!running_slideshow) 259 if (!iv->running_slideshow)
265 { 260 {
266 rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); 261 rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height);
267 rb->lcd_update(); 262 rb->lcd_update();
@@ -303,3 +298,13 @@ int get_image(struct image_info *info, int ds)
303 298
304 return PLUGIN_OK; 299 return PLUGIN_OK;
305} 300}
301
302const struct image_decoder image_decoder = {
303 true,
304 img_mem,
305 load_image,
306 get_image,
307 draw_image_rect,
308};
309
310IMGDEC_HEADER
diff --git a/apps/plugins/imageviewer/png/png.make b/apps/plugins/imageviewer/png/png.make
index 0a7106d2a9..dee89acb71 100644
--- a/apps/plugins/imageviewer/png/png.make
+++ b/apps/plugins/imageviewer/png/png.make
@@ -10,18 +10,19 @@
10PNGSRCDIR := $(IMGVSRCDIR)/png 10PNGSRCDIR := $(IMGVSRCDIR)/png
11PNGBUILDDIR := $(IMGVBUILDDIR)/png 11PNGBUILDDIR := $(IMGVBUILDDIR)/png
12 12
13ROCKS += $(PNGBUILDDIR)/png.rock
14
15PNG_SRC := $(call preprocess, $(PNGSRCDIR)/SOURCES) 13PNG_SRC := $(call preprocess, $(PNGSRCDIR)/SOURCES)
16PNG_OBJ := $(call c2obj, $(PNG_SRC)) 14PNG_OBJ := $(call c2obj, $(PNG_SRC))
17 15
18# add source files to OTHER_SRC to get automatic dependencies
19OTHER_SRC += $(PNG_SRC) 16OTHER_SRC += $(PNG_SRC)
20 17
21# Use -O3 for png plugin : it gives a bigger file but very good performances 18ROCKS += $(PNGBUILDDIR)/png.ovl
22PNGFLAGS = $(PLUGINFLAGS) -Os
23 19
24$(PNGBUILDDIR)/png.rock: $(PNG_OBJ) 20$(PNGBUILDDIR)/png.refmap: $(PNG_OBJ)
21$(PNGBUILDDIR)/png.link: $(PNG_OBJ) $(PNGBUILDDIR)/png.refmap
22$(PNGBUILDDIR)/png.ovl: $(PNG_OBJ)
23
24# Use -O3 for png plugin : it gives a bigger file but very good performances
25PNGFLAGS = $(IMGDECFLAGS) -Os
25 26
26# Compile PNG plugin with extra flags (adapted from ZXBox) 27# Compile PNG plugin with extra flags (adapted from ZXBox)
27$(PNGBUILDDIR)/%.o: $(PNGSRCDIR)/%.c $(PNGSRCDIR)/png.make 28$(PNGBUILDDIR)/%.o: $(PNGSRCDIR)/%.c $(PNGSRCDIR)/png.make
diff --git a/apps/plugins/imageviewer/png/png_ui.c b/apps/plugins/imageviewer/png/png_ui.c
deleted file mode 100644
index 5dbf526ba1..0000000000
--- a/apps/plugins/imageviewer/png/png_ui.c
+++ /dev/null
@@ -1,5 +0,0 @@
1#define PNG_VIEWER
2#define MENU_TITLE "Png Menu"
3#define UNSCALED_IS_AVAILABLE 1
4
5#include "../imageviewer.c"