Update font bitmap mix method, fix
@@ -423,16 +423,17 @@ static void FontBitmap_MixARGB( LCUI_Graph *graph, LCUI_Rect *write_rect,
int x, y;
LCUI_ARGB *px, *px_row_des;
uchar_t *byte_ptr, *byte_row_ptr;
- double a, out_a, out_r, out_g, out_b, src_a;
+ double a, ca, out_a, out_r, out_g, out_b, src_a;
byte_row_ptr = bmp->buffer + read_rect->y * bmp->width;
+ px_row_des = graph->argb + write_rect->y * graph->width;
byte_row_ptr += read_rect->x;
- px_row_des = graph->argb + write_rect->y * graph->w;
px_row_des += write_rect->x;
+ ca = color.alpha / 255.0;
for( y = 0; y < read_rect->height; ++y ) {
px = px_row_des;
byte_ptr = byte_row_ptr;
for( x = 0; x < read_rect->width; ++x, ++byte_ptr, ++px ) {
- src_a = *byte_ptr / 255.0;
+ src_a = *byte_ptr / 255.0 * ca;
a = (1.0 - src_a) * px->a / 255.0;
out_r = px->r * a + color.r * src_a;
out_g = px->g * a + color.g * src_a;
@@ -458,7 +459,7 @@ static void FontBitmap_MixRGB( LCUI_Graph *graph, LCUI_Rect *write_rect,
LCUI_Rect *read_rect )
{
int x, y;
- uchar_t *byte_src, *byte_row_src, *byte_row_des, *byte_des;
+ uchar_t *byte_src, *byte_row_src, *byte_row_des, *byte_des, alpha;
byte_row_src = bmp->buffer + read_rect->y*bmp->width + read_rect->x;
byte_row_des = graph->bytes + write_rect->y * graph->bytes_per_row;
byte_row_des += write_rect->x*graph->bytes_per_pixel;
@@ -466,12 +467,13 @@ static void FontBitmap_MixRGB( LCUI_Graph *graph, LCUI_Rect *write_rect,
byte_src = byte_row_src;
byte_des = byte_row_des;
for( x = 0; x < read_rect->width; ++x ) {
- ALPHA_BLEND( *byte_des, color.b, *byte_src );
- byte_des++;
- ALPHA_BLEND( *byte_des, color.g, *byte_src );
- byte_des++;
- ALPHA_BLEND( *byte_des, color.r, *byte_src );
- byte_des++;
+ alpha = (uchar_t)(*byte_src * color.alpha / 255);
+ ALPHA_BLEND( *byte_des, color.b, alpha );
+ ++byte_des;
+ ALPHA_BLEND( *byte_des, color.g, alpha );
+ ++byte_des;
+ ALPHA_BLEND( *byte_des, color.r, alpha );
+ ++byte_des;
++byte_src;
}
byte_row_des += graph->bytes_per_row;
