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/imageviewer.h | |
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/imageviewer.h')
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.h | 104 |
1 files changed, 77 insertions, 27 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.h b/apps/plugins/imageviewer/imageviewer.h index da2bbfe45c..8e838def08 100644 --- a/apps/plugins/imageviewer/imageviewer.h +++ b/apps/plugins/imageviewer/imageviewer.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * user intereface of image viewers (jpeg, png, etc.) | 10 | * user intereface of image viewer. |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -19,8 +19,8 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef _IMGVIEW_IMGVIEW_H | 22 | #ifndef _IMAGE_VIEWER_H |
23 | #define _IMGVIEW_IMGVIEW_H | 23 | #define _IMAGE_VIEWER_H |
24 | 24 | ||
25 | #include "plugin.h" | 25 | #include "plugin.h" |
26 | 26 | ||
@@ -384,6 +384,13 @@ | |||
384 | 384 | ||
385 | #include <lib/mylcd.h> | 385 | #include <lib/mylcd.h> |
386 | 386 | ||
387 | #if defined(USEGSLIB) && defined(IMGDEC) | ||
388 | #undef mylcd_ub_ | ||
389 | #undef myxlcd_ub_ | ||
390 | #define mylcd_ub_(fn) iv->fn | ||
391 | #define myxlcd_ub_(fn) iv->fn | ||
392 | #endif | ||
393 | |||
387 | /* Min memory allowing us to use the plugin buffer | 394 | /* Min memory allowing us to use the plugin buffer |
388 | * and thus not stopping the music | 395 | * and thus not stopping the music |
389 | * *Very* rough estimation: | 396 | * *Very* rough estimation: |
@@ -413,7 +420,6 @@ enum { | |||
413 | /* Settings. jpeg needs these */ | 420 | /* Settings. jpeg needs these */ |
414 | struct imgview_settings | 421 | struct imgview_settings |
415 | { | 422 | { |
416 | /* include all settings for varias decoders as using same setting file. */ | ||
417 | #ifdef HAVE_LCD_COLOR | 423 | #ifdef HAVE_LCD_COLOR |
418 | int jpeg_colour_mode; | 424 | int jpeg_colour_mode; |
419 | int jpeg_dither_mode; | 425 | int jpeg_dither_mode; |
@@ -421,7 +427,7 @@ struct imgview_settings | |||
421 | int ss_timeout; | 427 | int ss_timeout; |
422 | }; | 428 | }; |
423 | 429 | ||
424 | /* structure passed to decoder. */ | 430 | /* structure passed to image decoder. */ |
425 | struct image_info { | 431 | struct image_info { |
426 | int x_size, y_size; /* set size of loaded image in load_image(). */ | 432 | int x_size, y_size; /* set size of loaded image in load_image(). */ |
427 | int width, height; /* set size of resized image in get_image(). */ | 433 | int width, height; /* set size of resized image in get_image(). */ |
@@ -429,34 +435,78 @@ struct image_info { | |||
429 | void *data; /* use freely in decoder. not touched in ui. */ | 435 | void *data; /* use freely in decoder. not touched in ui. */ |
430 | }; | 436 | }; |
431 | 437 | ||
432 | /* callback updating a progress meter while image decoding */ | 438 | struct imgdec_api { |
433 | extern void cb_progress(int current, int total); | 439 | const struct imgview_settings *settings; |
434 | 440 | bool slideshow_enabled; /* run slideshow */ | |
435 | extern struct imgview_settings settings; | 441 | bool running_slideshow; /* loading image because of slideshw */ |
436 | extern bool slideshow_enabled; | ||
437 | extern bool running_slideshow; | ||
438 | #ifdef DISK_SPINDOWN | 442 | #ifdef DISK_SPINDOWN |
439 | extern bool immediate_ata_off; | 443 | bool immediate_ata_off; /* power down disk after loading */ |
440 | #endif | 444 | #endif |
441 | #ifdef USE_PLUG_BUF | 445 | #ifdef USE_PLUG_BUF |
442 | extern bool plug_buf; | 446 | bool plug_buf; /* are we using the plugin buffer or the audio buffer? */ |
443 | #endif | 447 | #endif |
444 | 448 | ||
449 | /* callback updating a progress meter while image decoding */ | ||
450 | void (*cb_progress)(int current, int total); | ||
451 | |||
452 | #ifdef USEGSLIB | ||
453 | void (*gray_bitmap_part)(const unsigned char *src, int src_x, int src_y, | ||
454 | int stride, int x, int y, int width, int height); | ||
455 | #endif | ||
456 | }; | ||
457 | |||
445 | /* functions need to be implemented in each image decoders. */ | 458 | /* functions need to be implemented in each image decoders. */ |
446 | /* return true if ext is supported by the decoder. */ | 459 | struct image_decoder { |
447 | extern bool img_ext(const char *ext); | 460 | /* if unscaled image can be always displayed when there isn't enough memory |
448 | /* return needed size of buffer to store downscaled image by ds */ | 461 | * for resized image. e.g. when using native format to store image. */ |
449 | extern int img_mem(int ds); | 462 | const bool unscaled_avail; |
450 | /* load image from filename. set width and height of info properly. also, set | 463 | |
451 | * buf_size to remaining size of buf after load image. it is used to caluclate | 464 | /* return needed size of buffer to store downscaled image by ds */ |
452 | * min downscale. */ | 465 | int (*img_mem)(int ds); |
453 | extern int load_image(char *filename, struct image_info *info, | 466 | /* load image from filename. set width and height of info properly. also, set |
467 | * buf_size to remaining size of buf after load image. it is used to caluclate | ||
468 | * min downscale. */ | ||
469 | int (*load_image)(char *filename, struct image_info *info, | ||
454 | unsigned char *buf, ssize_t *buf_size); | 470 | unsigned char *buf, ssize_t *buf_size); |
455 | /* downscale loaded image by ds. note that buf to store reszied image is not | 471 | /* downscale loaded image by ds. note that buf to store reszied image is not |
456 | * provided. return PLUGIN_ERROR for error. ui will skip to next image. */ | 472 | * provided. return PLUGIN_ERROR for error. ui will skip to next image. */ |
457 | extern int get_image(struct image_info *info, int ds); | 473 | int (*get_image)(struct image_info *info, int ds); |
458 | /* draw part of image */ | 474 | /* draw part of image */ |
459 | extern void draw_image_rect(struct image_info *info, | 475 | void (*draw_image_rect)(struct image_info *info, |
460 | int x, int y, int width, int height); | 476 | int x, int y, int width, int height); |
477 | }; | ||
478 | |||
479 | #define IMGDEC_API_VERSION (PLUGIN_API_VERSION << 4 | 0) | ||
480 | |||
481 | /* image decoder header */ | ||
482 | struct imgdec_header { | ||
483 | struct lc_header lc_hdr; /* must be the first */ | ||
484 | const struct image_decoder *decoder; | ||
485 | const struct plugin_api **api; | ||
486 | const struct imgdec_api **img_api; | ||
487 | }; | ||
488 | |||
489 | #ifdef IMGDEC | ||
490 | extern const struct imgdec_api *iv; | ||
491 | extern const struct image_decoder image_decoder; | ||
492 | |||
493 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | ||
494 | #define IMGDEC_HEADER \ | ||
495 | const struct plugin_api *rb DATA_ATTR; \ | ||
496 | const struct imgdec_api *iv DATA_ATTR; \ | ||
497 | const struct imgdec_header __header \ | ||
498 | __attribute__ ((section (".header")))= { \ | ||
499 | { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, \ | ||
500 | plugin_start_addr, plugin_end_addr }, &image_decoder, &rb, &iv }; | ||
501 | #else /* PLATFORM_HOSTED */ | ||
502 | #define IMGDEC_HEADER \ | ||
503 | const struct plugin_api *rb DATA_ATTR; \ | ||
504 | const struct imgdec_api *iv DATA_ATTR; \ | ||
505 | const struct imgdec_header __header \ | ||
506 | __attribute__((visibility("default"))) = { \ | ||
507 | { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, \ | ||
508 | NULL, NULL }, &image_decoder, &rb, &iv }; | ||
509 | #endif /* CONFIG_PLATFORM */ | ||
510 | #endif | ||
461 | 511 | ||
462 | #endif /* _IMGVIEW_IMGVIEW_H */ | 512 | #endif /* _IMAGE_VIEWER_H */ |