summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/pluginlib_bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/pluginlib_bmp.c')
-rw-r--r--apps/plugins/lib/pluginlib_bmp.c29
1 files changed, 21 insertions, 8 deletions
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
95void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) 102void 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"