diff options
Diffstat (limited to 'apps/plugins/lib/bmp.c')
-rw-r--r-- | apps/plugins/lib/bmp.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/apps/plugins/lib/bmp.c b/apps/plugins/lib/bmp.c index dc8432f76a..03bdc73783 100644 --- a/apps/plugins/lib/bmp.c +++ b/apps/plugins/lib/bmp.c | |||
@@ -82,3 +82,36 @@ int save_bmp_file( char* filename, struct bitmap *bm, struct plugin_api* rb ) | |||
82 | rb->close( fh ); | 82 | rb->close( fh ); |
83 | return 1; | 83 | return 1; |
84 | } | 84 | } |
85 | |||
86 | /** | ||
87 | Very simple image scale from src to dst (nearest neighbour). | ||
88 | Source and destination dimensions are read from the struct bitmap. | ||
89 | */ | ||
90 | void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | ||
91 | { | ||
92 | const int srcw = src->width; | ||
93 | const int srch = src->height; | ||
94 | const int dstw = dst->width; | ||
95 | const int dsth = dst->height; | ||
96 | const fb_data *srcd = (fb_data*)(src->data); | ||
97 | const fb_data *dstd = (fb_data*)(dst->data); | ||
98 | |||
99 | const long xrstep = ((srcw-1) << 8) / (dstw-1); | ||
100 | const long yrstep = ((srch-1) << 8) / (dsth-1); | ||
101 | fb_data *src_row, *dst_row; | ||
102 | long xr, yr = 0; | ||
103 | int src_x, src_y, dst_x, dst_y; | ||
104 | for (dst_y=0; dst_y < dsth; dst_y++) | ||
105 | { | ||
106 | src_y = (yr >> 8); | ||
107 | src_row = (fb_data*)&srcd[src_y * srcw]; | ||
108 | dst_row = (fb_data*)&dstd[dst_y * dstw]; | ||
109 | for (xr=0,dst_x=0; dst_x < dstw; dst_x++) | ||
110 | { | ||
111 | src_x = (xr >> 8); | ||
112 | dst_row[dst_x] = src_row[src_x]; | ||
113 | xr += xrstep; | ||
114 | } | ||
115 | yr += yrstep; | ||
116 | } | ||
117 | } | ||