diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-01-28 23:12:20 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-01-28 23:12:20 +0000 |
commit | 281403a4d839924df41480fc020f401211a6e88b (patch) | |
tree | a9465e88b9f0c660f2080578d1839bd5f4d2ddc7 | |
parent | 5947e49f467cdf3cf5d2acfcc3c0bd6f97ab29f7 (diff) | |
download | rockbox-281403a4d839924df41480fc020f401211a6e88b.tar.gz rockbox-281403a4d839924df41480fc020f401211a6e88b.zip |
Work-in-progress transparent bitmaps with 255,0,255 as the transparent color, not yet working on the H100 series
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8476 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/gwps-common.c | 9 | ||||
-rw-r--r-- | apps/screen_access.c | 6 | ||||
-rw-r--r-- | apps/screen_access.h | 2 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 58 | ||||
-rw-r--r-- | firmware/export/lcd.h | 11 |
5 files changed, 82 insertions, 4 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index d15dbba888..b32deba479 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -219,7 +219,7 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf, | |||
219 | data->img[n].bm.data = data->img_buf_ptr; | 219 | data->img[n].bm.data = data->img_buf_ptr; |
220 | ret = read_bmp_file(imgname, &data->img[n].bm, | 220 | ret = read_bmp_file(imgname, &data->img[n].bm, |
221 | data->img_buf_free, | 221 | data->img_buf_free, |
222 | FORMAT_ANY); | 222 | FORMAT_ANY|FORMAT_TRANSPARENT); |
223 | if (ret > 0) | 223 | if (ret > 0) |
224 | { | 224 | { |
225 | data->img_buf_ptr += ret; | 225 | data->img_buf_ptr += ret; |
@@ -1252,9 +1252,10 @@ static void wps_draw_image(struct gui_wps *gwps, int n) | |||
1252 | data->img[n].bm.height); | 1252 | data->img[n].bm.height); |
1253 | #if LCD_DEPTH > 1 | 1253 | #if LCD_DEPTH > 1 |
1254 | } else { | 1254 | } else { |
1255 | display->bitmap((fb_data *)data->img[n].bm.data, data->img[n].x, | 1255 | display->transparent_bitmap((fb_data *)data->img[n].bm.data, |
1256 | data->img[n].y, data->img[n].bm.width, | 1256 | data->img[n].x, |
1257 | data->img[n].bm.height); | 1257 | data->img[n].y, data->img[n].bm.width, |
1258 | data->img[n].bm.height); | ||
1258 | } | 1259 | } |
1259 | #endif | 1260 | #endif |
1260 | } | 1261 | } |
diff --git a/apps/screen_access.c b/apps/screen_access.c index 8f7f5c5aae..d38f1ca6a9 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c | |||
@@ -121,6 +121,12 @@ void screen_init(struct screen * screen, enum screen_type screen_type) | |||
121 | screen->set_drawmode=&lcd_set_drawmode; | 121 | screen->set_drawmode=&lcd_set_drawmode; |
122 | #if LCD_DEPTH > 1 | 122 | #if LCD_DEPTH > 1 |
123 | screen->bitmap=&lcd_bitmap; | 123 | screen->bitmap=&lcd_bitmap; |
124 | #if LCD_DEPTH == 2 | ||
125 | /* No transparency yet for grayscale lcd */ | ||
126 | screen->transparent_bitmap=&lcd_bitmap; | ||
127 | #else | ||
128 | screen->transparent_bitmap=&lcd_bitmap_transparent; | ||
129 | #endif | ||
124 | screen->set_background=&lcd_set_background; | 130 | screen->set_background=&lcd_set_background; |
125 | #endif | 131 | #endif |
126 | screen->update_rect=&lcd_update_rect; | 132 | screen->update_rect=&lcd_update_rect; |
diff --git a/apps/screen_access.h b/apps/screen_access.h index af52527fc0..3664ecb13d 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h | |||
@@ -84,6 +84,8 @@ struct screen | |||
84 | int x, int y, int width, int height); | 84 | int x, int y, int width, int height); |
85 | void (*bitmap)(const fb_data *src, | 85 | void (*bitmap)(const fb_data *src, |
86 | int x, int y, int width, int height); | 86 | int x, int y, int width, int height); |
87 | void (*transparent_bitmap)(const fb_data *src, | ||
88 | int x, int y, int width, int height); | ||
87 | void (*set_drawmode)(int mode); | 89 | void (*set_drawmode)(int mode); |
88 | #if (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) | 90 | #if (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) |
89 | void (*set_background)(unsigned background); | 91 | void (*set_background)(unsigned background); |
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 |