diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2010-09-29 20:38:08 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2010-09-29 20:38:08 +0000 |
commit | 289e862695a6194ade9f7782cab63a7cbc19c066 (patch) | |
tree | 70f02b68d2f1fea7b1ccb72aaf9469e353776ae9 /apps/plugins/lib | |
parent | 717f0bd982004a3df0445d7747f04ab46ea3f6d5 (diff) | |
download | rockbox-289e862695a6194ade9f7782cab63a7cbc19c066.tar.gz rockbox-289e862695a6194ade9f7782cab63a7cbc19c066.zip |
fix bitmap scallers smooth_resize_bitmap() and simple_resize_bitmap() to properly handle LCD_STRIDEFORMAT == VERTICAL_STRIDE case
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28185 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/bmp_smooth_scale.c | 7 | ||||
-rw-r--r-- | apps/plugins/lib/pluginlib_bmp.c | 29 |
2 files changed, 28 insertions, 8 deletions
diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c index 4d5eab00a0..e99ff33d71 100644 --- a/apps/plugins/lib/bmp_smooth_scale.c +++ b/apps/plugins/lib/bmp_smooth_scale.c | |||
@@ -78,10 +78,17 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) | |||
78 | fb_data *sptr, *dptr; | 78 | fb_data *sptr, *dptr; |
79 | int x, y, end; | 79 | int x, y, end; |
80 | int val_y = 0, val_x; | 80 | int val_y = 0, val_x; |
81 | #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE | ||
82 | const int sw = src_bmp->height; | ||
83 | const int sh = src_bmp->width; | ||
84 | const int dw = dest_bmp->height; | ||
85 | const int dh = dest_bmp->width; | ||
86 | #else | ||
81 | const int sw = src_bmp->width; | 87 | const int sw = src_bmp->width; |
82 | const int sh = src_bmp->height; | 88 | const int sh = src_bmp->height; |
83 | const int dw = dest_bmp->width; | 89 | const int dw = dest_bmp->width; |
84 | const int dh = dest_bmp->height; | 90 | const int dh = dest_bmp->height; |
91 | #endif | ||
85 | const int inc_x = (sw << 16) / dw; | 92 | const int inc_x = (sw << 16) / dw; |
86 | const int inc_y = (sh << 16) / dh; | 93 | const int inc_y = (sh << 16) / dh; |
87 | const int Cp_x = ((dw << 14) / sw) + 1; | 94 | const int Cp_x = ((dw << 14) / sw) + 1; |
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c index 148aa8e1de..708abfa4a4 100644 --- a/apps/plugins/lib/pluginlib_bmp.c +++ b/apps/plugins/lib/pluginlib_bmp.c | |||
@@ -86,31 +86,45 @@ int save_bmp_file( char* filename, struct bitmap *bm ) | |||
86 | rb->close( fh ); | 86 | rb->close( fh ); |
87 | return 1; | 87 | return 1; |
88 | } | 88 | } |
89 | #endif | 89 | #endif /* HAVE_LCD_COLOR */ |
90 | 90 | ||
91 | /** | 91 | /** |
92 | Very simple image scale from src to dst (nearest neighbour). | 92 | Very simple image scale from src to dst (nearest neighbour). |
93 | Source and destination dimensions are read from the struct bitmap. | 93 | Source and destination dimensions are read from the struct bitmap. |
94 | |||
95 | FB_DATA define is to properly scale with greylib | ||
94 | */ | 96 | */ |
97 | #if LCD_DEPTH > 8 | ||
98 | #define FB_DATA fb_data | ||
99 | #else | ||
100 | #define FB_DATA unsigned char | ||
101 | #endif | ||
95 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | 102 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) |
96 | { | 103 | { |
104 | #if defined(LCD_STRIDEFORMAT) && \ | ||
105 | (LCD_STRIDEFORMAT == VERTICAL_STRIDE) | ||
106 | const int srcw = src->height; | ||
107 | const int srch = src->width; | ||
108 | const int dstw = dst->height; | ||
109 | const int dsth = dst->width; | ||
110 | #else | ||
97 | const int srcw = src->width; | 111 | const int srcw = src->width; |
98 | const int srch = src->height; | 112 | const int srch = src->height; |
99 | const int dstw = dst->width; | 113 | const int dstw = dst->width; |
100 | const int dsth = dst->height; | 114 | const int dsth = dst->height; |
101 | const fb_data *srcd = (fb_data*)(src->data); | 115 | #endif |
102 | const fb_data *dstd = (fb_data*)(dst->data); | 116 | const FB_DATA *srcd = (FB_DATA *)(src->data); |
103 | 117 | const FB_DATA *dstd = (FB_DATA *)(dst->data); | |
104 | const long xrstep = ((srcw-1) << 8) / (dstw-1); | 118 | const long xrstep = ((srcw-1) << 8) / (dstw-1); |
105 | const long yrstep = ((srch-1) << 8) / (dsth-1); | 119 | const long yrstep = ((srch-1) << 8) / (dsth-1); |
106 | fb_data *src_row, *dst_row; | 120 | FB_DATA *src_row, *dst_row; |
107 | long xr, yr = 0; | 121 | long xr, yr = 0; |
108 | int src_x, src_y, dst_x, dst_y; | 122 | int src_x, src_y, dst_x, dst_y; |
109 | for (dst_y=0; dst_y < dsth; dst_y++) | 123 | for (dst_y=0; dst_y < dsth; dst_y++) |
110 | { | 124 | { |
111 | src_y = (yr >> 8); | 125 | src_y = (yr >> 8); |
112 | src_row = (fb_data*)&srcd[src_y * srcw]; | 126 | src_row = (FB_DATA *)&srcd[src_y * srcw]; |
113 | dst_row = (fb_data*)&dstd[dst_y * dstw]; | 127 | dst_row = (FB_DATA *)&dstd[dst_y * dstw]; |
114 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) | 128 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) |
115 | { | 129 | { |
116 | src_x = (xr >> 8); | 130 | src_x = (xr >> 8); |
@@ -120,7 +134,6 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | |||
120 | yr += yrstep; | 134 | yr += yrstep; |
121 | } | 135 | } |
122 | } | 136 | } |
123 | |||
124 | #endif /* LCD_DEPTH > 1 */ | 137 | #endif /* LCD_DEPTH > 1 */ |
125 | 138 | ||
126 | #include "wrappers.h" | 139 | #include "wrappers.h" |