diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2011-01-16 12:45:11 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2011-01-16 12:45:11 +0000 |
commit | 62207228f717d0eb29aca5d1fbc155f151d6814e (patch) | |
tree | 551cc0ec6f34c3f289439e34b91e16c9ad89e85d /apps/plugins | |
parent | 5c09844d54c7adba80fd261e83a4c895d007a576 (diff) | |
download | rockbox-62207228f717d0eb29aca5d1fbc155f151d6814e.tar.gz rockbox-62207228f717d0eb29aca5d1fbc155f151d6814e.zip |
image viewer: add quick guide describing how to add image decoder. also improve comments.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29066 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.h | 21 | ||||
-rw-r--r-- | apps/plugins/imageviewer/readme.txt | 37 |
2 files changed, 50 insertions, 8 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.h b/apps/plugins/imageviewer/imageviewer.h index 504ef2bb3a..f35c1c7e6d 100644 --- a/apps/plugins/imageviewer/imageviewer.h +++ b/apps/plugins/imageviewer/imageviewer.h | |||
@@ -469,19 +469,24 @@ struct imgdec_api { | |||
469 | 469 | ||
470 | /* functions need to be implemented in each image decoders. */ | 470 | /* functions need to be implemented in each image decoders. */ |
471 | struct image_decoder { | 471 | struct image_decoder { |
472 | /* if unscaled image can be always displayed when there isn't enough memory | 472 | /* set true if unscaled image can be always displayed even when there isn't |
473 | * for resized image. e.g. when using native format to store image. */ | 473 | * enough memory for resized image. e.g. when using native format to store |
474 | * image. */ | ||
474 | const bool unscaled_avail; | 475 | const bool unscaled_avail; |
475 | 476 | ||
476 | /* return needed size of buffer to store downscaled image by ds */ | 477 | /* return needed size of buffer to store downscaled image by ds. |
478 | * this is used to calculate min downscale. */ | ||
477 | int (*img_mem)(int ds); | 479 | int (*img_mem)(int ds); |
478 | /* load image from filename. set width and height of info properly. also, set | 480 | /* load image from filename. use the passed buffer to store loaded, decoded |
479 | * buf_size to remaining size of buf after load image. it is used to caluclate | 481 | * or resized image later, so save it to local variables if needed. |
480 | * min downscale. */ | 482 | * set width and height of info properly. also, set buf_size to remaining |
483 | * size of buf after load image. it is used to calculate min downscale. | ||
484 | * return PLUGIN_ERROR for error. ui will skip to next image. */ | ||
481 | int (*load_image)(char *filename, struct image_info *info, | 485 | int (*load_image)(char *filename, struct image_info *info, |
482 | unsigned char *buf, ssize_t *buf_size); | 486 | unsigned char *buf, ssize_t *buf_size); |
483 | /* downscale loaded image by ds. note that buf to store reszied image is not | 487 | /* downscale loaded image by ds. use the buffer passed to load_image to |
484 | * provided. return PLUGIN_ERROR for error. ui will skip to next image. */ | 488 | * reszie image and/or store resized image. |
489 | * return PLUGIN_ERROR for error. ui will skip to next image. */ | ||
485 | int (*get_image)(struct image_info *info, int ds); | 490 | int (*get_image)(struct image_info *info, int ds); |
486 | /* draw part of image */ | 491 | /* draw part of image */ |
487 | void (*draw_image_rect)(struct image_info *info, | 492 | void (*draw_image_rect)(struct image_info *info, |
diff --git a/apps/plugins/imageviewer/readme.txt b/apps/plugins/imageviewer/readme.txt new file mode 100644 index 0000000000..b7ec71e7be --- /dev/null +++ b/apps/plugins/imageviewer/readme.txt | |||
@@ -0,0 +1,37 @@ | |||
1 | this document describes how to add new image decoder. | ||
2 | |||
3 | 1. create a directory which name is your image decoder's name and put source files | ||
4 | under the directory. | ||
5 | 'const struct image_decoder image_decoder' and 'IMGDEC_HEADER' must be declared in | ||
6 | one of your source files. | ||
7 | see imageviewer.h for the detail of struct image_decoder. | ||
8 | |||
9 | 2. add the directory name to apps/plugins/imageviewer/SUBDIR so that the decoder | ||
10 | is built. | ||
11 | if the decoder is supported by particular targets, surround it with #if directive. | ||
12 | e.g. if the decoder supports color LCD targets only, | ||
13 | #ifdef HAVE_LCD_COLOR | ||
14 | bmp | ||
15 | #endif | ||
16 | |||
17 | 3. append appropriate entry to enum image_type in image_decoder.h, decoder_names | ||
18 | and ext_list in image_decoder.c so that the imageviewer plugin can recognize | ||
19 | the decoder. | ||
20 | if the decoder is supported by particular targets, surround them with same #if | ||
21 | directive in SUBDIR. | ||
22 | |||
23 | 4. add entry to apps/plugins/viewers.config | ||
24 | (in format: file_extension,viewer/imageviewer) so that the file with specified | ||
25 | file extension will be opened by image viewer plugin. | ||
26 | if the decoder is supported by particular targets, surround it with same #if | ||
27 | directive in SUBDIR. | ||
28 | |||
29 | 5. add entry to apps/plugins/CATEGORIES (in format: decoder_name,viewer) so | ||
30 | that the build file is copied to viewers directory. | ||
31 | DON'T surround this with #if directive. | ||
32 | |||
33 | |||
34 | notes: | ||
35 | if you need to use greylib functions to draw image, add the functions to | ||
36 | struct imgdec_api just like gray_bitmap_part because GREY_INFO_STRUCT is | ||
37 | declared in imageviewer and is not available from the decoder. | ||