From: Ray Strode Date: Fri, 30 May 2008 14:23:22 +0000 (-0400) Subject: add new function ply_frame_buffer_fill_with_hex_color_at_opacity X-Git-Tag: 0.1.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ea6b9c8b705be54094a49d40803b992f0df38b0;p=thirdparty%2Fplymouth.git add new function ply_frame_buffer_fill_with_hex_color_at_opacity It's sometimes useful to specify an opacity to fill with for the passed in color, too, independent of its alpha. --- diff --git a/src/libply/ply-frame-buffer.c b/src/libply/ply-frame-buffer.c index 0ed6e727..5b09d76a 100644 --- a/src/libply/ply-frame-buffer.c +++ b/src/libply/ply-frame-buffer.c @@ -673,9 +673,10 @@ ply_frame_buffer_fill_with_color (ply_frame_buffer_t *buffer, } bool -ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, - ply_frame_buffer_area_t *area, - uint32_t hex_color) +ply_frame_buffer_fill_with_hex_color_at_opacity (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + uint32_t hex_color, + double opacity) { ply_frame_buffer_area_t cropped_area; uint32_t pixel_value; @@ -702,6 +703,8 @@ ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, blue = ((double) (hex_color & 0x0000ff00) / 0x0000ff00); alpha = ((double) (hex_color & 0x000000ff) / 0x000000ff); + alpha *= opacity; + red *= alpha; green *= alpha; blue *= alpha; @@ -715,6 +718,14 @@ ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, return ply_frame_buffer_flush (buffer); } +bool +ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + uint32_t hex_color) +{ + return ply_frame_buffer_fill_with_hex_color_at_opacity (buffer, area, hex_color, 1.0); +} + bool ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buffer, ply_frame_buffer_area_t *area, diff --git a/src/libply/ply-frame-buffer.h b/src/libply/ply-frame-buffer.h index a3e406a9..a4d259fc 100644 --- a/src/libply/ply-frame-buffer.h +++ b/src/libply/ply-frame-buffer.h @@ -67,6 +67,11 @@ bool ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, ply_frame_buffer_area_t *area, uint32_t hex_color); +bool ply_frame_buffer_fill_with_hex_color_at_opacity (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + uint32_t hex_color, + double opacity); + bool ply_frame_buffer_fill_with_argb32_data (ply_frame_buffer_t *buffer, ply_frame_buffer_area_t *area, unsigned long x,