diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 58 | ||||
-rw-r--r-- | firmware/export/lcd.h | 11 |
2 files changed, 69 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index b13e4cee90..4a6348f9db 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -540,6 +540,64 @@ void lcd_bitmap(const fb_data *src, int x, int y, int width, int height) | |||
540 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); | 540 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); |
541 | } | 541 | } |
542 | 542 | ||
543 | /* Draw a partial native bitmap */ | ||
544 | void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y, | ||
545 | int stride, int x, int y, int width, | ||
546 | int height) ICODE_ATTR; | ||
547 | void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y, | ||
548 | int stride, int x, int y, int width, | ||
549 | int height) | ||
550 | { | ||
551 | fb_data *dst, *dst_end; | ||
552 | |||
553 | /* nothing to draw? */ | ||
554 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | ||
555 | || (x + width <= 0) || (y + height <= 0)) | ||
556 | return; | ||
557 | |||
558 | /* clipping */ | ||
559 | if (x < 0) | ||
560 | { | ||
561 | width += x; | ||
562 | src_x -= x; | ||
563 | x = 0; | ||
564 | } | ||
565 | if (y < 0) | ||
566 | { | ||
567 | height += y; | ||
568 | src_y -= y; | ||
569 | y = 0; | ||
570 | } | ||
571 | if (x + width > LCD_WIDTH) | ||
572 | width = LCD_WIDTH - x; | ||
573 | if (y + height > LCD_HEIGHT) | ||
574 | height = LCD_HEIGHT - y; | ||
575 | |||
576 | src += stride * src_y + src_x; /* move starting point */ | ||
577 | dst = LCDADDR(x, y); | ||
578 | dst_end = dst + height * LCD_WIDTH; | ||
579 | |||
580 | do | ||
581 | { | ||
582 | int i; | ||
583 | for(i = 0;i < width;i++) | ||
584 | { | ||
585 | if(src[i] != TRANSPARENT_COLOR) | ||
586 | dst[i] = src[i]; | ||
587 | } | ||
588 | src += stride; | ||
589 | dst += LCD_WIDTH; | ||
590 | } | ||
591 | while (dst < dst_end); | ||
592 | } | ||
593 | |||
594 | /* Draw a full native bitmap with a transparent color */ | ||
595 | void lcd_bitmap_transparent(const fb_data *src, int x, int y, | ||
596 | int width, int height) | ||
597 | { | ||
598 | lcd_bitmap_transparent_part(src, 0, 0, width, x, y, width, height); | ||
599 | } | ||
600 | |||
543 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 601 | /* put a string at a given pixel position, skipping first ofs pixel columns */ |
544 | static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) | 602 | static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) |
545 | { | 603 | { |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 393e91f93e..f4c40fb88c 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -201,11 +201,16 @@ enum | |||
201 | FORMAT_ANY /* For passing to read_bmp_file() */ | 201 | FORMAT_ANY /* For passing to read_bmp_file() */ |
202 | }; | 202 | }; |
203 | 203 | ||
204 | #define FORMAT_TRANSPARENT 0x40000000 | ||
205 | |||
206 | #define TRANSPARENT_COLOR LCD_RGBPACK(255,0,255) | ||
207 | |||
204 | struct bitmap { | 208 | struct bitmap { |
205 | int width; | 209 | int width; |
206 | int height; | 210 | int height; |
207 | #if LCD_DEPTH > 1 | 211 | #if LCD_DEPTH > 1 |
208 | int format; | 212 | int format; |
213 | unsigned char *maskdata; | ||
209 | #endif | 214 | #endif |
210 | unsigned char *data; | 215 | unsigned char *data; |
211 | }; | 216 | }; |
@@ -265,6 +270,12 @@ extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
265 | int stride, int x, int y, int width, int height); | 270 | int stride, int x, int y, int width, int height); |
266 | extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, | 271 | extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, |
267 | int height); | 272 | int height); |
273 | extern void lcd_bitmap_transparent_part(const fb_data *src, | ||
274 | int src_x, int src_y, | ||
275 | int stride, int x, int y, int width, | ||
276 | int height); | ||
277 | extern void lcd_bitmap_transparent(const fb_data *src, int x, int y, | ||
278 | int width, int height); | ||
268 | #else /* LCD_DEPTH == 1 */ | 279 | #else /* LCD_DEPTH == 1 */ |
269 | #define lcd_mono_bitmap lcd_bitmap | 280 | #define lcd_mono_bitmap lcd_bitmap |
270 | #define lcd_mono_bitmap_part lcd_bitmap_part | 281 | #define lcd_mono_bitmap_part lcd_bitmap_part |