summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/lib/playergfx.c45
-rw-r--r--apps/plugins/lib/playergfx.h2
2 files changed, 40 insertions, 7 deletions
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
index d227d608a7..51e003b048 100644
--- a/apps/plugins/lib/playergfx.c
+++ b/apps/plugins/lib/playergfx.c
@@ -28,8 +28,8 @@
28static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */ 28static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
29static int char_width; 29static int char_width;
30static int char_height; 30static int char_height;
31static int pixel_height; 31static unsigned pixel_height;
32static int pixel_width; 32static unsigned pixel_width;
33static unsigned char gfx_chars[8]; 33static unsigned char gfx_chars[8];
34static unsigned char gfx_buffer[56]; 34static unsigned char gfx_buffer[56];
35 35
@@ -200,14 +200,12 @@ void pgfx_invertrect (int x, int y, int nx, int ny)
200{ 200{
201 int i, j; 201 int i, j;
202 202
203 if (x > pixel_width) 203 if (((unsigned) x >= pixel_width) || ((unsigned) y >= pixel_height))
204 return;
205 if (y > pixel_height)
206 return; 204 return;
207 205
208 if (x + nx > pixel_width) 206 if ((unsigned)(x + nx) > pixel_width)
209 nx = pixel_width - x; 207 nx = pixel_width - x;
210 if (y + ny > pixel_height) 208 if ((unsigned)(y + ny) > pixel_height)
211 ny = pixel_height - y; 209 ny = pixel_height - y;
212 210
213 for (i = 0; i < nx; i++) 211 for (i = 0; i < nx; i++)
@@ -215,4 +213,37 @@ void pgfx_invertrect (int x, int y, int nx, int ny)
215 pgfx_invertpixel(x + i, y + j); 213 pgfx_invertpixel(x + i, y + j);
216} 214}
217 215
216void pgfx_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
217 bool clear)
218{
219 int stride, i, j;
220 unsigned data;
221
222 if (((unsigned) x >= pixel_width) || ((unsigned) y >= pixel_height))
223 return;
224
225 stride = nx; /* otherwise right-clipping will destroy the image */
226
227 if (((unsigned)(x + nx)) >= pixel_width)
228 nx = pixel_width - x;
229 if (((unsigned)(y + ny)) >= pixel_height)
230 ny = pixel_height - y;
231
232 for (i = 0; i < nx; i++, src++)
233 {
234 data = src[0];
235 if (ny > 8) /* ny is max. 14 */
236 data |= src[stride] << 8;
237 for (j = 0; j < ny; j++)
238 {
239 if (data & 1)
240 pgfx_drawpixel(x + i, y + j);
241 else
242 if (clear)
243 pgfx_clearpixel(x + i, y + j);
244 data >>= 1;
245 }
246 }
247}
248
218#endif /* HAVE_LCD_CHARCELLS */ 249#endif /* HAVE_LCD_CHARCELLS */
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h
index 98664117aa..ced484398e 100644
--- a/apps/plugins/lib/playergfx.h
+++ b/apps/plugins/lib/playergfx.h
@@ -38,6 +38,8 @@ void pgfx_drawline(int x1, int y1, int x2, int y2);
38void pgfx_clearline(int x1, int y1, int x2, int y2); 38void pgfx_clearline(int x1, int y1, int x2, int y2);
39void pgfx_invertline(int x1, int y1, int x2, int y2); 39void pgfx_invertline(int x1, int y1, int x2, int y2);
40void pgfx_invertrect (int x, int y, int nx, int ny); 40void pgfx_invertrect (int x, int y, int nx, int ny);
41void pgfx_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
42 bool clear);
41 43
42#endif /* HAVE_LCD_CHARCELLS */ 44#endif /* HAVE_LCD_CHARCELLS */
43#endif /* __PGFX_H__ */ 45#endif /* __PGFX_H__ */