diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-02 03:47:46 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-02 03:47:46 +0000 |
commit | 3d4c68bb060bc926a1da72d6c00b86ebb87857c7 (patch) | |
tree | 4a49d1671ca28faa5e06c1851b6b6de41969e4fc | |
parent | 75f2629778a55d5b59ecb57e326879964610b063 (diff) | |
download | rockbox-3d4c68bb060bc926a1da72d6c00b86ebb87857c7.tar.gz rockbox-3d4c68bb060bc926a1da72d6c00b86ebb87857c7.zip |
Add read_<image>_fd functions to plugin API, add feature_wrappers.h handling for them, and add read_image.[ch] wrapper for reading image files with automatic type detection.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20840 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugin.c | 6 | ||||
-rw-r--r-- | apps/plugin.h | 12 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/feature_wrappers.h | 2 | ||||
-rw-r--r-- | apps/plugins/lib/read_image.c | 55 | ||||
-rw-r--r-- | apps/plugins/lib/read_image.h | 34 |
6 files changed, 105 insertions, 5 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 7ebb2aa12f..33a6194c53 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -643,8 +643,12 @@ static const struct plugin_api rockbox_api = { | |||
643 | lcd_pal256_update_pal, | 643 | lcd_pal256_update_pal, |
644 | #endif | 644 | #endif |
645 | #endif | 645 | #endif |
646 | #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH > 1 | 646 | #ifdef HAVE_LCD_BITMAP |
647 | #if LCD_DEPTH > 1 | ||
647 | read_jpeg_file, | 648 | read_jpeg_file, |
649 | read_jpeg_fd, | ||
650 | #endif | ||
651 | read_bmp_fd, | ||
648 | #endif | 652 | #endif |
649 | }; | 653 | }; |
650 | 654 | ||
diff --git a/apps/plugin.h b/apps/plugin.h index ab570d473e..19eb962588 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -79,9 +79,7 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
79 | #ifdef HAVE_LCD_BITMAP | 79 | #ifdef HAVE_LCD_BITMAP |
80 | #include "screendump.h" | 80 | #include "screendump.h" |
81 | #include "scrollbar.h" | 81 | #include "scrollbar.h" |
82 | #if LCD_DEPTH > 1 | ||
83 | #include "jpeg_load.h" | 82 | #include "jpeg_load.h" |
84 | #endif | ||
85 | #include "../recorder/bmp.h" | 83 | #include "../recorder/bmp.h" |
86 | #endif | 84 | #endif |
87 | #include "statusbar.h" | 85 | #include "statusbar.h" |
@@ -131,7 +129,7 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
131 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 129 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
132 | 130 | ||
133 | /* increase this every time the api struct changes */ | 131 | /* increase this every time the api struct changes */ |
134 | #define PLUGIN_API_VERSION 148 | 132 | #define PLUGIN_API_VERSION 149 |
135 | 133 | ||
136 | /* update this to latest version if a change to the api struct breaks | 134 | /* update this to latest version if a change to the api struct breaks |
137 | backwards compatibility (and please take the opportunity to sort in any | 135 | backwards compatibility (and please take the opportunity to sort in any |
@@ -806,9 +804,15 @@ struct plugin_api { | |||
806 | #endif | 804 | #endif |
807 | #endif | 805 | #endif |
808 | 806 | ||
809 | #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH > 1 | 807 | #ifdef HAVE_LCD_BITMAP |
808 | #if LCD_DEPTH > 1 | ||
810 | int (*read_jpeg_file)(const char* filename, struct bitmap *bm, int maxsize, | 809 | int (*read_jpeg_file)(const char* filename, struct bitmap *bm, int maxsize, |
811 | int format, const struct custom_format *cformat); | 810 | int format, const struct custom_format *cformat); |
811 | int (*read_jpeg_fd)(int fd, struct bitmap *bm, int maxsize, | ||
812 | int format, const struct custom_format *cformat); | ||
813 | #endif | ||
814 | int (*read_bmp_fd)(int fd, struct bitmap *bm, int maxsize, | ||
815 | int format, const struct custom_format *cformat); | ||
812 | #endif | 816 | #endif |
813 | }; | 817 | }; |
814 | 818 | ||
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 7dda416a87..dfdd569843 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -41,6 +41,7 @@ xlcd_core.c | |||
41 | xlcd_draw.c | 41 | xlcd_draw.c |
42 | xlcd_scroll.c | 42 | xlcd_scroll.c |
43 | pluginlib_bmp.c | 43 | pluginlib_bmp.c |
44 | read_image.c | ||
44 | #ifdef HAVE_LCD_COLOR | 45 | #ifdef HAVE_LCD_COLOR |
45 | bmp_smooth_scale.c | 46 | bmp_smooth_scale.c |
46 | #endif | 47 | #endif |
diff --git a/apps/plugins/lib/feature_wrappers.h b/apps/plugins/lib/feature_wrappers.h index 22ce779fcd..cf840e6d57 100644 --- a/apps/plugins/lib/feature_wrappers.h +++ b/apps/plugins/lib/feature_wrappers.h | |||
@@ -43,8 +43,10 @@ | |||
43 | */ | 43 | */ |
44 | #if LCD_DEPTH > 1 | 44 | #if LCD_DEPTH > 1 |
45 | #define scaled_read_bmp_file rb->read_bmp_file | 45 | #define scaled_read_bmp_file rb->read_bmp_file |
46 | #define scaled_read_bmp_fd rb->read_bmp_fd | ||
46 | #else | 47 | #else |
47 | #define scaled_read_bmp_file read_bmp_file | 48 | #define scaled_read_bmp_file read_bmp_file |
49 | #define scaled_read_bmp_fd read_bmp_fd | ||
48 | #endif | 50 | #endif |
49 | 51 | ||
50 | #endif | 52 | #endif |
diff --git a/apps/plugins/lib/read_image.c b/apps/plugins/lib/read_image.c new file mode 100644 index 0000000000..0420ed8188 --- /dev/null +++ b/apps/plugins/lib/read_image.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Andrew Mahone | ||
11 | * | ||
12 | * This is a wrapper for the core jpeg_load.c | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include <plugin.h> | ||
25 | #include "feature_wrappers.h" | ||
26 | |||
27 | int read_image_file(const char* filename, struct bitmap *bm, int maxsize, | ||
28 | int format, const struct custom_format *cformat) | ||
29 | { | ||
30 | #if LCD_DEPTH > 1 | ||
31 | int namelen = rb->strlen(filename); | ||
32 | if (rb->strcmp(filename + namelen - 4, ".bmp")) | ||
33 | return read_jpeg_file(filename, bm, maxsize, format, cformat); | ||
34 | else | ||
35 | #endif | ||
36 | return scaled_read_bmp_file(filename, bm, maxsize, format, cformat); | ||
37 | } | ||
38 | |||
39 | int read_image_file_offset(int offset, const char* filename, struct bitmap *bm, | ||
40 | int maxsize, int format, | ||
41 | const struct custom_format *cformat) | ||
42 | { | ||
43 | int fd = rb->open(filename, O_RDONLY); | ||
44 | if (fd < 0) | ||
45 | return fd; | ||
46 | if (offset != rb->lseek(fd, offset, SEEK_SET)) | ||
47 | return -1; | ||
48 | #if LCD_DEPTH > 1 | ||
49 | int namelen = rb->strlen(filename); | ||
50 | if (rb->strcmp(filename + namelen - 4, ".bmp")) | ||
51 | return read_jpeg_fd(fd, bm, maxsize, format, cformat); | ||
52 | else | ||
53 | #endif | ||
54 | return scaled_read_bmp_fd(fd, bm, maxsize, format, cformat); | ||
55 | } | ||
diff --git a/apps/plugins/lib/read_image.h b/apps/plugins/lib/read_image.h new file mode 100644 index 0000000000..3e236688fe --- /dev/null +++ b/apps/plugins/lib/read_image.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Andrew Mahone | ||
11 | * | ||
12 | * This is a wrapper for the core jpeg_load.c | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #ifndef _LIB_READ_IMAGE_H_ | ||
25 | #define _LIB_READ_IMAGE_H_ | ||
26 | #include <plugin.h> | ||
27 | |||
28 | int read_image_file(const char* filename, struct bitmap *bm, int maxsize, | ||
29 | int format, const struct custom_format *cformat); | ||
30 | int read_image_file_offset(int offset, const char* filename, struct bitmap *bm, | ||
31 | int maxsize, int format, | ||
32 | const struct custom_format *cformat); | ||
33 | #endif | ||
34 | |||