1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * user intereface of image viewers (jpeg, png, etc.)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef _IMGVIEW_IMGVIEW_H
23 #define _IMGVIEW_IMGVIEW_H
27 /* variable button definitions */
28 #if CONFIG_KEYPAD == RECORDER_PAD
29 #define IMGVIEW_ZOOM_IN BUTTON_PLAY
30 #define IMGVIEW_ZOOM_OUT BUTTON_ON
31 #define IMGVIEW_UP BUTTON_UP
32 #define IMGVIEW_DOWN BUTTON_DOWN
33 #define IMGVIEW_LEFT BUTTON_LEFT
34 #define IMGVIEW_RIGHT BUTTON_RIGHT
35 #define IMGVIEW_NEXT BUTTON_F3
36 #define IMGVIEW_PREVIOUS BUTTON_F2
37 #define IMGVIEW_MENU BUTTON_OFF
39 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
40 #define IMGVIEW_ZOOM_IN BUTTON_SELECT
41 #define IMGVIEW_ZOOM_OUT BUTTON_ON
42 #define IMGVIEW_UP BUTTON_UP
43 #define IMGVIEW_DOWN BUTTON_DOWN
44 #define IMGVIEW_LEFT BUTTON_LEFT
45 #define IMGVIEW_RIGHT BUTTON_RIGHT
46 #define IMGVIEW_NEXT BUTTON_F3
47 #define IMGVIEW_PREVIOUS BUTTON_F2
48 #define IMGVIEW_MENU BUTTON_OFF
50 #elif CONFIG_KEYPAD == ONDIO_PAD
51 #define IMGVIEW_ZOOM_PRE BUTTON_MENU
52 #define IMGVIEW_ZOOM_IN (BUTTON_MENU | BUTTON_REL)
53 #define IMGVIEW_ZOOM_OUT (BUTTON_MENU | BUTTON_DOWN)
54 #define IMGVIEW_UP BUTTON_UP
55 #define IMGVIEW_DOWN BUTTON_DOWN
56 #define IMGVIEW_LEFT BUTTON_LEFT
57 #define IMGVIEW_RIGHT BUTTON_RIGHT
58 #define IMGVIEW_NEXT (BUTTON_MENU | BUTTON_RIGHT)
59 #define IMGVIEW_PREVIOUS (BUTTON_MENU | BUTTON_LEFT)
60 #define IMGVIEW_MENU BUTTON_OFF
62 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
63 (CONFIG_KEYPAD == IRIVER_H300_PAD)
64 #define IMGVIEW_ZOOM_IN BUTTON_SELECT
65 #define IMGVIEW_ZOOM_OUT BUTTON_MODE
66 #define IMGVIEW_UP BUTTON_UP
67 #define IMGVIEW_DOWN BUTTON_DOWN
68 #define IMGVIEW_LEFT BUTTON_LEFT
69 #define IMGVIEW_RIGHT BUTTON_RIGHT
70 #if (CONFIG_KEYPAD == IRIVER_H100_PAD)
71 #define IMGVIEW_NEXT BUTTON_ON
72 #define IMGVIEW_PREVIOUS BUTTON_REC
74 #define IMGVIEW_NEXT BUTTON_REC
75 #define IMGVIEW_PREVIOUS BUTTON_ON
77 #define IMGVIEW_MENU BUTTON_OFF
78 #define IMGVIEW_RC_MENU BUTTON_RC_STOP
80 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
81 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
82 #define IMGVIEW_ZOOM_IN BUTTON_SCROLL_FWD
83 #define IMGVIEW_ZOOM_OUT BUTTON_SCROLL_BACK
84 #define IMGVIEW_UP BUTTON_MENU
85 #define IMGVIEW_DOWN BUTTON_PLAY
86 #define IMGVIEW_LEFT BUTTON_LEFT
87 #define IMGVIEW_RIGHT BUTTON_RIGHT
88 #define IMGVIEW_NEXT (BUTTON_SELECT | BUTTON_RIGHT)
89 #define IMGVIEW_PREVIOUS (BUTTON_SELECT | BUTTON_LEFT)
90 #define IMGVIEW_MENU (BUTTON_SELECT | BUTTON_MENU)
92 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
93 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
94 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
95 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
96 #define IMGVIEW_UP BUTTON_UP
97 #define IMGVIEW_DOWN BUTTON_DOWN
98 #define IMGVIEW_LEFT BUTTON_LEFT
99 #define IMGVIEW_RIGHT BUTTON_RIGHT
100 #define IMGVIEW_NEXT BUTTON_PLAY
101 #define IMGVIEW_PREVIOUS BUTTON_REC
102 #define IMGVIEW_MENU BUTTON_POWER
104 #elif CONFIG_KEYPAD == GIGABEAT_PAD
105 #define IMGVIEW_ZOOM_IN BUTTON_VOL_UP
106 #define IMGVIEW_ZOOM_OUT BUTTON_VOL_DOWN
107 #define IMGVIEW_UP BUTTON_UP
108 #define IMGVIEW_DOWN BUTTON_DOWN
109 #define IMGVIEW_LEFT BUTTON_LEFT
110 #define IMGVIEW_RIGHT BUTTON_RIGHT
111 #define IMGVIEW_NEXT (BUTTON_A | BUTTON_RIGHT)
112 #define IMGVIEW_PREVIOUS (BUTTON_A | BUTTON_LEFT)
113 #define IMGVIEW_MENU BUTTON_MENU
115 #elif CONFIG_KEYPAD == SANSA_E200_PAD
116 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
117 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
118 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
119 #define IMGVIEW_UP BUTTON_UP
120 #define IMGVIEW_DOWN BUTTON_DOWN
121 #define IMGVIEW_LEFT BUTTON_LEFT
122 #define IMGVIEW_RIGHT BUTTON_RIGHT
123 #define IMGVIEW_NEXT BUTTON_SCROLL_FWD
124 #define IMGVIEW_NEXT_REPEAT (BUTTON_SCROLL_FWD|BUTTON_REPEAT)
125 #define IMGVIEW_PREVIOUS BUTTON_SCROLL_BACK
126 #define IMGVIEW_PREVIOUS_REPEAT (BUTTON_SCROLL_BACK|BUTTON_REPEAT)
127 #define IMGVIEW_MENU BUTTON_POWER
128 #define IMGVIEW_SLIDE_SHOW BUTTON_REC
130 #elif CONFIG_KEYPAD == SANSA_FUZE_PAD
131 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
132 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
133 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
134 #define IMGVIEW_UP BUTTON_UP
135 #define IMGVIEW_DOWN BUTTON_DOWN
136 #define IMGVIEW_LEFT BUTTON_LEFT
137 #define IMGVIEW_RIGHT BUTTON_RIGHT
138 #define IMGVIEW_NEXT BUTTON_SCROLL_FWD
139 #define IMGVIEW_NEXT_REPEAT (BUTTON_SCROLL_FWD|BUTTON_REPEAT)
140 #define IMGVIEW_PREVIOUS BUTTON_SCROLL_BACK
141 #define IMGVIEW_PREVIOUS_REPEAT (BUTTON_SCROLL_BACK|BUTTON_REPEAT)
142 #define IMGVIEW_MENU (BUTTON_HOME|BUTTON_REPEAT)
144 #elif CONFIG_KEYPAD == SANSA_C200_PAD
145 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
146 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
147 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
148 #define IMGVIEW_UP BUTTON_UP
149 #define IMGVIEW_DOWN BUTTON_DOWN
150 #define IMGVIEW_LEFT BUTTON_LEFT
151 #define IMGVIEW_RIGHT BUTTON_RIGHT
152 #define IMGVIEW_NEXT BUTTON_VOL_UP
153 #define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
154 #define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
155 #define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
156 #define IMGVIEW_MENU BUTTON_POWER
157 #define IMGVIEW_SLIDE_SHOW BUTTON_REC
159 #elif CONFIG_KEYPAD == SANSA_CLIP_PAD
160 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
161 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
162 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
163 #define IMGVIEW_UP BUTTON_UP
164 #define IMGVIEW_DOWN BUTTON_DOWN
165 #define IMGVIEW_LEFT BUTTON_LEFT
166 #define IMGVIEW_RIGHT BUTTON_RIGHT
167 #define IMGVIEW_NEXT BUTTON_VOL_UP
168 #define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
169 #define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
170 #define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
171 #define IMGVIEW_MENU BUTTON_POWER
172 #define IMGVIEW_SLIDE_SHOW BUTTON_HOME
174 #elif CONFIG_KEYPAD == SANSA_M200_PAD
175 #define IMGVIEW_ZOOM_PRE BUTTON_SELECT
176 #define IMGVIEW_ZOOM_IN (BUTTON_SELECT | BUTTON_REL)
177 #define IMGVIEW_ZOOM_OUT (BUTTON_SELECT | BUTTON_REPEAT)
178 #define IMGVIEW_UP BUTTON_UP
179 #define IMGVIEW_DOWN BUTTON_DOWN
180 #define IMGVIEW_LEFT BUTTON_LEFT
181 #define IMGVIEW_RIGHT BUTTON_RIGHT
182 #define IMGVIEW_NEXT BUTTON_VOL_UP
183 #define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
184 #define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
185 #define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
186 #define IMGVIEW_MENU BUTTON_POWER
187 #define IMGVIEW_SLIDE_SHOW (BUTTON_SELECT | BUTTON_UP)
189 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
190 #define IMGVIEW_ZOOM_PRE BUTTON_PLAY
191 #define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
192 #define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT)
193 #define IMGVIEW_UP BUTTON_SCROLL_UP
194 #define IMGVIEW_DOWN BUTTON_SCROLL_DOWN
195 #define IMGVIEW_LEFT BUTTON_LEFT
196 #define IMGVIEW_RIGHT BUTTON_RIGHT
197 #define IMGVIEW_NEXT BUTTON_FF
198 #define IMGVIEW_PREVIOUS BUTTON_REW
199 #define IMGVIEW_MENU BUTTON_POWER
201 #elif CONFIG_KEYPAD == MROBE500_PAD
202 #define IMGVIEW_MENU BUTTON_POWER
204 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
205 #define IMGVIEW_ZOOM_IN BUTTON_VOL_UP
206 #define IMGVIEW_ZOOM_OUT BUTTON_VOL_DOWN
207 #define IMGVIEW_UP BUTTON_UP
208 #define IMGVIEW_DOWN BUTTON_DOWN
209 #define IMGVIEW_LEFT BUTTON_LEFT
210 #define IMGVIEW_RIGHT BUTTON_RIGHT
211 #define IMGVIEW_NEXT BUTTON_NEXT
212 #define IMGVIEW_PREVIOUS BUTTON_PREV
213 #define IMGVIEW_MENU BUTTON_MENU
215 #elif CONFIG_KEYPAD == MROBE100_PAD
216 #define IMGVIEW_ZOOM_IN BUTTON_SELECT
217 #define IMGVIEW_ZOOM_OUT BUTTON_PLAY
218 #define IMGVIEW_UP BUTTON_UP
219 #define IMGVIEW_DOWN BUTTON_DOWN
220 #define IMGVIEW_LEFT BUTTON_LEFT
221 #define IMGVIEW_RIGHT BUTTON_RIGHT
222 #define IMGVIEW_NEXT (BUTTON_DISPLAY | BUTTON_RIGHT)
223 #define IMGVIEW_PREVIOUS (BUTTON_DISPLAY | BUTTON_LEFT)
224 #define IMGVIEW_MENU BUTTON_MENU
226 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
227 #define IMGVIEW_ZOOM_PRE BUTTON_RC_PLAY
228 #define IMGVIEW_ZOOM_IN (BUTTON_RC_PLAY|BUTTON_REL)
229 #define IMGVIEW_ZOOM_OUT (BUTTON_RC_PLAY|BUTTON_REPEAT)
230 #define IMGVIEW_UP BUTTON_RC_VOL_UP
231 #define IMGVIEW_DOWN BUTTON_RC_VOL_DOWN
232 #define IMGVIEW_LEFT BUTTON_RC_REW
233 #define IMGVIEW_RIGHT BUTTON_RC_FF
234 #define IMGVIEW_NEXT BUTTON_RC_MODE
235 #define IMGVIEW_PREVIOUS BUTTON_RC_MENU
236 #define IMGVIEW_MENU BUTTON_RC_REC
238 #elif CONFIG_KEYPAD == COWON_D2_PAD
240 #elif CONFIG_KEYPAD == IAUDIO67_PAD
241 #define IMGVIEW_ZOOM_IN BUTTON_VOLUP
242 #define IMGVIEW_ZOOM_OUT BUTTON_VOLDOWN
243 #define IMGVIEW_UP BUTTON_STOP
244 #define IMGVIEW_DOWN BUTTON_PLAY
245 #define IMGVIEW_LEFT BUTTON_LEFT
246 #define IMGVIEW_RIGHT BUTTON_RIGHT
247 #define IMGVIEW_NEXT (BUTTON_PLAY|BUTTON_VOLUP)
248 #define IMGVIEW_PREVIOUS (BUTTON_PLAY|BUTTON_VOLDOWN)
249 #define IMGVIEW_MENU BUTTON_MENU
251 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
253 #define IMGVIEW_ZOOM_IN BUTTON_PLAY
254 #define IMGVIEW_ZOOM_OUT BUTTON_CUSTOM
255 #define IMGVIEW_UP BUTTON_UP
256 #define IMGVIEW_DOWN BUTTON_DOWN
257 #define IMGVIEW_LEFT BUTTON_LEFT
258 #define IMGVIEW_RIGHT BUTTON_RIGHT
259 #define IMGVIEW_NEXT BUTTON_SELECT
260 #define IMGVIEW_PREVIOUS BUTTON_BACK
261 #define IMGVIEW_MENU BUTTON_MENU
263 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
264 #define IMGVIEW_ZOOM_IN BUTTON_VOL_UP
265 #define IMGVIEW_ZOOM_OUT BUTTON_VOL_DOWN
266 #define IMGVIEW_UP BUTTON_UP
267 #define IMGVIEW_DOWN BUTTON_DOWN
268 #define IMGVIEW_LEFT BUTTON_LEFT
269 #define IMGVIEW_RIGHT BUTTON_RIGHT
270 #define IMGVIEW_NEXT BUTTON_VIEW
271 #define IMGVIEW_PREVIOUS BUTTON_PLAYLIST
272 #define IMGVIEW_MENU BUTTON_MENU
274 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
275 #define IMGVIEW_ZOOM_IN BUTTON_VOL_UP
276 #define IMGVIEW_ZOOM_OUT BUTTON_VOL_DOWN
277 #define IMGVIEW_UP BUTTON_UP
278 #define IMGVIEW_DOWN BUTTON_DOWN
279 #define IMGVIEW_LEFT BUTTON_PREV
280 #define IMGVIEW_RIGHT BUTTON_NEXT
281 #define IMGVIEW_NEXT BUTTON_RIGHT
282 #define IMGVIEW_PREVIOUS BUTTON_LEFT
283 #define IMGVIEW_MENU BUTTON_MENU
285 #elif CONFIG_KEYPAD == ONDAVX747_PAD
286 #elif CONFIG_KEYPAD == ONDAVX777_PAD
288 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
289 #define IMGVIEW_ZOOM_IN (BUTTON_PLAY|BUTTON_UP)
290 #define IMGVIEW_ZOOM_OUT (BUTTON_PLAY|BUTTON_DOWN)
291 #define IMGVIEW_UP BUTTON_UP
292 #define IMGVIEW_DOWN BUTTON_DOWN
293 #define IMGVIEW_LEFT BUTTON_LEFT
294 #define IMGVIEW_RIGHT BUTTON_RIGHT
295 #define IMGVIEW_NEXT BUTTON_FFWD
296 #define IMGVIEW_PREVIOUS BUTTON_REW
297 #define IMGVIEW_MENU BUTTON_PLAY
300 #error No keymap defined!
303 #ifdef HAVE_TOUCHSCREEN
305 #define IMGVIEW_UP BUTTON_TOPMIDDLE
308 #define IMGVIEW_DOWN BUTTON_BOTTOMMIDDLE
311 #define IMGVIEW_LEFT BUTTON_MIDLEFT
313 #ifndef IMGVIEW_RIGHT
314 #define IMGVIEW_RIGHT BUTTON_MIDRIGHT
316 #ifndef IMGVIEW_ZOOM_IN
317 #define IMGVIEW_ZOOM_IN BUTTON_TOPRIGHT
319 #ifndef IMGVIEW_ZOOM_OUT
320 #define IMGVIEW_ZOOM_OUT BUTTON_TOPLEFT
323 #define IMGVIEW_MENU (BUTTON_CENTER|BUTTON_REL)
326 #define IMGVIEW_NEXT BUTTON_BOTTOMRIGHT
328 #ifndef IMGVIEW_PREVIOUS
329 #define IMGVIEW_PREVIOUS BUTTON_BOTTOMLEFT
333 /* different graphics libraries */
336 #include <lib/grey.h>
337 #define MYLCD(fn) grey_ub_ ## fn
338 #define MYLCD_UPDATE()
339 #define MYXLCD(fn) grey_ub_ ## fn
341 #include <lib/xlcd.h>
342 #define MYLCD(fn) rb->lcd_ ## fn
343 #define MYLCD_UPDATE() rb->lcd_update();
344 #define MYXLCD(fn) xlcd_ ## fn
347 /* Min memory allowing us to use the plugin buffer
348 * and thus not stopping the music
349 * *Very* rough estimation:
350 * Max 10 000 dir entries * 4bytes/entry (char **) = 40000 bytes
351 * + 30k code size = 70 000
352 * + 50k min for image = 120 000
354 #define MIN_MEM 120000
356 /* State code for output with return. */
357 #define PLUGIN_OTHER 10
358 #define PLUGIN_ABORT 11
359 #define PLUGIN_OUTOFMEM 12
361 #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE)
362 #define DISK_SPINDOWN
365 /* Settings. jpeg needs these */
366 struct imgview_settings
368 /* include all settings for varias decoders as using same setting file. */
369 #ifdef HAVE_LCD_COLOR
370 int jpeg_colour_mode
;
371 int jpeg_dither_mode
;
376 /* structure passed to decoder. */
378 int x_size
, y_size
; /* set size of loaded image in load_image(). */
379 int width
, height
; /* set size of resized image in get_image(). */
380 int x
, y
; /* display position */
381 void *data
; /* use freely in decoder. not touched in ui. */
384 /* callback updating a progress meter while image decoding */
385 extern void cb_progress(int current
, int total
);
387 extern struct imgview_settings settings
;
388 extern bool slideshow_enabled
;
389 extern bool running_slideshow
;
391 extern bool immediate_ata_off
;
393 #if PLUGIN_BUFFER_SIZE >= MIN_MEM
394 extern bool plug_buf
;
397 /* functions need to be implemented in each image decoders. */
398 /* return true if ext is supported by the decoder. */
399 extern bool img_ext(const char *ext
);
400 /* return needed size of buffer to store downscaled image by ds */
401 extern int img_mem(int ds
);
402 /* load image from filename. set width and height of info properly. also, set
403 * buf_size to remaining size of buf after load image. it is used to caluclate
405 extern int load_image(char *filename
, struct image_info
*info
,
406 unsigned char *buf
, ssize_t
*buf_size
);
407 /* downscale loaded image by ds. note that buf to store reszied image is not
408 * provided. return PLUGIN_ERROR for error. ui will skip to next image. */
409 extern int get_image(struct image_info
*info
, int ds
);
410 /* draw part of image */
411 extern void draw_image_rect(struct image_info
*info
,
412 int x
, int y
, int width
, int height
);
414 #endif /* _IMGVIEW_IMGVIEW_H */