diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-10 14:24:11 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-10 14:24:11 +0000 |
commit | 38e88f35f49ad1e3fc58fe67771ecc3412541ae8 (patch) | |
tree | 2ba91d597ae7db801e6a38d359b170e8db151ba7 | |
parent | 8ad85ba291efab4056b4a75e3d7a30dc6db16ac4 (diff) | |
download | rockbox-38e88f35f49ad1e3fc58fe67771ecc3412541ae8.tar.gz rockbox-38e88f35f49ad1e3fc58fe67771ecc3412541ae8.zip |
use different function to resize bitmap for greylib.
it is confusing that same function expects different data type (fb_data or unsigned char) depending on the target.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28233 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/imageviewer/bmp/bmp.c | 4 | ||||
-rw-r--r-- | apps/plugins/lib/pluginlib_bmp.c | 57 | ||||
-rw-r--r-- | apps/plugins/lib/pluginlib_bmp.h | 9 |
3 files changed, 54 insertions, 16 deletions
diff --git a/apps/plugins/imageviewer/bmp/bmp.c b/apps/plugins/imageviewer/bmp/bmp.c index e12cb831d6..6d33575f98 100644 --- a/apps/plugins/imageviewer/bmp/bmp.c +++ b/apps/plugins/imageviewer/bmp/bmp.c | |||
@@ -27,8 +27,10 @@ | |||
27 | 27 | ||
28 | #include "../imageviewer.h" | 28 | #include "../imageviewer.h" |
29 | 29 | ||
30 | #if defined(HAVE_LCD_COLOR) | 30 | #ifdef HAVE_LCD_COLOR |
31 | #define resize_bitmap smooth_resize_bitmap | 31 | #define resize_bitmap smooth_resize_bitmap |
32 | #elif defined(USEGSLIB) | ||
33 | #define resize_bitmap grey_resize_bitmap | ||
32 | #else | 34 | #else |
33 | #define resize_bitmap simple_resize_bitmap | 35 | #define resize_bitmap simple_resize_bitmap |
34 | #endif | 36 | #endif |
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c index 535742ec78..f1dd9b7b38 100644 --- a/apps/plugins/lib/pluginlib_bmp.c +++ b/apps/plugins/lib/pluginlib_bmp.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "file.h" | 26 | #include "file.h" |
27 | #include "system.h" | 27 | #include "system.h" |
28 | 28 | ||
29 | #if defined(HAVE_LCD_COLOR) && LCD_DEPTH > 1 | 29 | #if defined(HAVE_LCD_COLOR) |
30 | #define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff | 30 | #define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff |
31 | #define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff | 31 | #define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff |
32 | /** | 32 | /** |
@@ -90,18 +90,11 @@ int save_bmp_file( char* filename, struct bitmap *bm ) | |||
90 | /** | 90 | /** |
91 | Very simple image scale from src to dst (nearest neighbour). | 91 | Very simple image scale from src to dst (nearest neighbour). |
92 | Source and destination dimensions are read from the struct bitmap. | 92 | Source and destination dimensions are read from the struct bitmap. |
93 | 93 | FIXME: this doesn't work well for LCD_DEPTH<4 | |
94 | FB_DATA define is to properly scale with greylib | ||
95 | */ | 94 | */ |
96 | #if LCD_DEPTH > 8 | ||
97 | #define FB_DATA fb_data | ||
98 | #else | ||
99 | #define FB_DATA unsigned char | ||
100 | #endif | ||
101 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | 95 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) |
102 | { | 96 | { |
103 | #if defined(LCD_STRIDEFORMAT) && \ | 97 | #if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) |
104 | (LCD_STRIDEFORMAT == VERTICAL_STRIDE) | ||
105 | const int srcw = src->height; | 98 | const int srcw = src->height; |
106 | const int srch = src->width; | 99 | const int srch = src->width; |
107 | const int dstw = dst->height; | 100 | const int dstw = dst->height; |
@@ -112,18 +105,18 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | |||
112 | const int dstw = dst->width; | 105 | const int dstw = dst->width; |
113 | const int dsth = dst->height; | 106 | const int dsth = dst->height; |
114 | #endif | 107 | #endif |
115 | const FB_DATA *srcd = (FB_DATA *)(src->data); | 108 | const fb_data *srcd = (fb_data *)(src->data); |
116 | const FB_DATA *dstd = (FB_DATA *)(dst->data); | 109 | const fb_data *dstd = (fb_data *)(dst->data); |
117 | const long xrstep = ((srcw-1) << 8) / (dstw-1); | 110 | const long xrstep = ((srcw-1) << 8) / (dstw-1); |
118 | const long yrstep = ((srch-1) << 8) / (dsth-1); | 111 | const long yrstep = ((srch-1) << 8) / (dsth-1); |
119 | FB_DATA *src_row, *dst_row; | 112 | fb_data *src_row, *dst_row; |
120 | long xr, yr = 0; | 113 | long xr, yr = 0; |
121 | int src_x, src_y, dst_x, dst_y; | 114 | int src_x, src_y, dst_x, dst_y; |
122 | for (dst_y=0; dst_y < dsth; dst_y++) | 115 | for (dst_y=0; dst_y < dsth; dst_y++) |
123 | { | 116 | { |
124 | src_y = (yr >> 8); | 117 | src_y = (yr >> 8); |
125 | src_row = (FB_DATA *)&srcd[src_y * srcw]; | 118 | src_row = (fb_data *)&srcd[src_y * srcw]; |
126 | dst_row = (FB_DATA *)&dstd[dst_y * dstw]; | 119 | dst_row = (fb_data *)&dstd[dst_y * dstw]; |
127 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) | 120 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) |
128 | { | 121 | { |
129 | src_x = (xr >> 8); | 122 | src_x = (xr >> 8); |
@@ -134,6 +127,40 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | |||
134 | } | 127 | } |
135 | } | 128 | } |
136 | 129 | ||
130 | #if (LCD_DEPTH < 4) | ||
131 | /** | ||
132 | Same as simple_resize_bitmap except this is for use with greylib. | ||
133 | */ | ||
134 | void grey_resize_bitmap(struct bitmap *src, struct bitmap *dst) | ||
135 | { | ||
136 | const int srcw = src->width; | ||
137 | const int srch = src->height; | ||
138 | const int dstw = dst->width; | ||
139 | const int dsth = dst->height; | ||
140 | const long xrstep = ((srcw-1) << 8) / (dstw-1); | ||
141 | const long yrstep = ((srch-1) << 8) / (dsth-1); | ||
142 | unsigned char *srcd = src->data; | ||
143 | unsigned char *dstd = dst->data; | ||
144 | unsigned char *src_row, *dst_row; | ||
145 | long xr, yr = 0; | ||
146 | int src_x, src_y, dst_x, dst_y; | ||
147 | for (dst_y=0; dst_y < dsth; dst_y++) | ||
148 | { | ||
149 | src_y = (yr >> 8); | ||
150 | src_row = &srcd[src_y * srcw]; | ||
151 | dst_row = &dstd[dst_y * dstw]; | ||
152 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) | ||
153 | { | ||
154 | src_x = (xr >> 8); | ||
155 | dst_row[dst_x] = src_row[src_x]; | ||
156 | xr += xrstep; | ||
157 | } | ||
158 | yr += yrstep; | ||
159 | } | ||
160 | } | ||
161 | #endif | ||
162 | |||
163 | |||
137 | #include "wrappers.h" | 164 | #include "wrappers.h" |
138 | 165 | ||
139 | /* import the core bmp loader */ | 166 | /* import the core bmp loader */ |
diff --git a/apps/plugins/lib/pluginlib_bmp.h b/apps/plugins/lib/pluginlib_bmp.h index 17844a8e38..be0cfd9091 100644 --- a/apps/plugins/lib/pluginlib_bmp.h +++ b/apps/plugins/lib/pluginlib_bmp.h | |||
@@ -37,10 +37,19 @@ int save_bmp_file( char* filename, struct bitmap *bm ); | |||
37 | */ | 37 | */ |
38 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); | 38 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); |
39 | 39 | ||
40 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) | ||
41 | /** | ||
42 | Same as simple_resize_bitmap except this is for use with greylib. | ||
43 | */ | ||
44 | void grey_resize_bitmap(struct bitmap *src, struct bitmap *dst); | ||
45 | #endif | ||
46 | |||
47 | #ifdef HAVE_LCD_COLOR | ||
40 | /** | 48 | /** |
41 | Advanced image scale from src to dst (bilinear) based on imlib2. | 49 | Advanced image scale from src to dst (bilinear) based on imlib2. |
42 | Source and destination dimensions are read from the struct bitmap. | 50 | Source and destination dimensions are read from the struct bitmap. |
43 | */ | 51 | */ |
44 | void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); | 52 | void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); |
53 | #endif | ||
45 | 54 | ||
46 | #endif | 55 | #endif |