mirror of
https://github.com/brl/mutter.git
synced 2024-11-13 01:36:10 -05:00
Add cogl_color_premultiply()
Add a convenience function to convert an ARGB color from non-premultiplied to premultiplied form. http://bugzilla.openedhand.com/show_bug.cgi?id=1406 Signed-off-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
19c2e66398
commit
f90017ab4e
@ -228,6 +228,18 @@ float cogl_color_get_blue (const CoglColor *color);
|
||||
*/
|
||||
float cogl_color_get_alpha (const CoglColor *color);
|
||||
|
||||
/**
|
||||
* cogl_color_premultiply:
|
||||
* @color: the color to premultiply
|
||||
*
|
||||
* Converts a non-premultiplied color to a pre-multiplied color. For
|
||||
* example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied
|
||||
* and (0.5, 0, 0, 0.5) when premultiplied.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void cogl_color_premultiply (CoglColor *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_COLOR_H__ */
|
||||
|
@ -153,6 +153,14 @@ cogl_color_get_alpha (const CoglColor *color)
|
||||
return ((float) color->alpha / 255.0);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_color_premultiply (CoglColor *color)
|
||||
{
|
||||
color->red = (color->red * color->alpha + 128) / 255;
|
||||
color->green = (color->green * color->alpha + 128) / 255;
|
||||
color->blue = (color->blue * color->alpha + 128) / 255;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_set_source_color4ub (guint8 red,
|
||||
guint8 green,
|
||||
|
Loading…
Reference in New Issue
Block a user