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
This commit is contained in:
parent
5947e49f46
commit
281403a4d8
|
@ -219,7 +219,7 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
|
|||
data->img[n].bm.data = data->img_buf_ptr;
|
||||
ret = read_bmp_file(imgname, &data->img[n].bm,
|
||||
data->img_buf_free,
|
||||
FORMAT_ANY);
|
||||
FORMAT_ANY|FORMAT_TRANSPARENT);
|
||||
if (ret > 0)
|
||||
{
|
||||
data->img_buf_ptr += ret;
|
||||
|
@ -1252,9 +1252,10 @@ static void wps_draw_image(struct gui_wps *gwps, int n)
|
|||
data->img[n].bm.height);
|
||||
#if LCD_DEPTH > 1
|
||||
} else {
|
||||
display->bitmap((fb_data *)data->img[n].bm.data, data->img[n].x,
|
||||
data->img[n].y, data->img[n].bm.width,
|
||||
data->img[n].bm.height);
|
||||
display->transparent_bitmap((fb_data *)data->img[n].bm.data,
|
||||
data->img[n].x,
|
||||
data->img[n].y, data->img[n].bm.width,
|
||||
data->img[n].bm.height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -121,6 +121,12 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
|
|||
screen->set_drawmode=&lcd_set_drawmode;
|
||||
#if LCD_DEPTH > 1
|
||||
screen->bitmap=&lcd_bitmap;
|
||||
#if LCD_DEPTH == 2
|
||||
/* No transparency yet for grayscale lcd */
|
||||
screen->transparent_bitmap=&lcd_bitmap;
|
||||
#else
|
||||
screen->transparent_bitmap=&lcd_bitmap_transparent;
|
||||
#endif
|
||||
screen->set_background=&lcd_set_background;
|
||||
#endif
|
||||
screen->update_rect=&lcd_update_rect;
|
||||
|
|
|
@ -84,6 +84,8 @@ struct screen
|
|||
int x, int y, int width, int height);
|
||||
void (*bitmap)(const fb_data *src,
|
||||
int x, int y, int width, int height);
|
||||
void (*transparent_bitmap)(const fb_data *src,
|
||||
int x, int y, int width, int height);
|
||||
void (*set_drawmode)(int mode);
|
||||
#if (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1)
|
||||
void (*set_background)(unsigned background);
|
||||
|
|
|
@ -540,6 +540,64 @@ void lcd_bitmap(const fb_data *src, int x, int y, int width, int height)
|
|||
lcd_bitmap_part(src, 0, 0, width, x, y, width, height);
|
||||
}
|
||||
|
||||
/* Draw a partial native bitmap */
|
||||
void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y,
|
||||
int stride, int x, int y, int width,
|
||||
int height) ICODE_ATTR;
|
||||
void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y,
|
||||
int stride, int x, int y, int width,
|
||||
int height)
|
||||
{
|
||||
fb_data *dst, *dst_end;
|
||||
|
||||
/* nothing to draw? */
|
||||
if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
|
||||
|| (x + width <= 0) || (y + height <= 0))
|
||||
return;
|
||||
|
||||
/* clipping */
|
||||
if (x < 0)
|
||||
{
|
||||
width += x;
|
||||
src_x -= x;
|
||||
x = 0;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
height += y;
|
||||
src_y -= y;
|
||||
y = 0;
|
||||
}
|
||||
if (x + width > LCD_WIDTH)
|
||||
width = LCD_WIDTH - x;
|
||||
if (y + height > LCD_HEIGHT)
|
||||
height = LCD_HEIGHT - y;
|
||||
|
||||
src += stride * src_y + src_x; /* move starting point */
|
||||
dst = LCDADDR(x, y);
|
||||
dst_end = dst + height * LCD_WIDTH;
|
||||
|
||||
do
|
||||
{
|
||||
int i;
|
||||
for(i = 0;i < width;i++)
|
||||
{
|
||||
if(src[i] != TRANSPARENT_COLOR)
|
||||
dst[i] = src[i];
|
||||
}
|
||||
src += stride;
|
||||
dst += LCD_WIDTH;
|
||||
}
|
||||
while (dst < dst_end);
|
||||
}
|
||||
|
||||
/* Draw a full native bitmap with a transparent color */
|
||||
void lcd_bitmap_transparent(const fb_data *src, int x, int y,
|
||||
int width, int height)
|
||||
{
|
||||
lcd_bitmap_transparent_part(src, 0, 0, width, x, y, width, height);
|
||||
}
|
||||
|
||||
/* put a string at a given pixel position, skipping first ofs pixel columns */
|
||||
static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str)
|
||||
{
|
||||
|
|
|
@ -201,11 +201,16 @@ enum
|
|||
FORMAT_ANY /* For passing to read_bmp_file() */
|
||||
};
|
||||
|
||||
#define FORMAT_TRANSPARENT 0x40000000
|
||||
|
||||
#define TRANSPARENT_COLOR LCD_RGBPACK(255,0,255)
|
||||
|
||||
struct bitmap {
|
||||
int width;
|
||||
int height;
|
||||
#if LCD_DEPTH > 1
|
||||
int format;
|
||||
unsigned char *maskdata;
|
||||
#endif
|
||||
unsigned char *data;
|
||||
};
|
||||
|
@ -265,6 +270,12 @@ extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
int stride, int x, int y, int width, int height);
|
||||
extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,
|
||||
int height);
|
||||
extern void lcd_bitmap_transparent_part(const fb_data *src,
|
||||
int src_x, int src_y,
|
||||
int stride, int x, int y, int width,
|
||||
int height);
|
||||
extern void lcd_bitmap_transparent(const fb_data *src, int x, int y,
|
||||
int width, int height);
|
||||
#else /* LCD_DEPTH == 1 */
|
||||
#define lcd_mono_bitmap lcd_bitmap
|
||||
#define lcd_mono_bitmap_part lcd_bitmap_part
|
||||
|
|
Loading…
Reference in New Issue
Block a user