mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00: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);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_COLOR_H__ */
|
#endif /* __COGL_COLOR_H__ */
|
||||||
|
@ -153,6 +153,14 @@ cogl_color_get_alpha (const CoglColor *color)
|
|||||||
return ((float) color->alpha / 255.0);
|
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
|
void
|
||||||
cogl_set_source_color4ub (guint8 red,
|
cogl_set_source_color4ub (guint8 red,
|
||||||
guint8 green,
|
guint8 green,
|
||||||
|
Loading…
Reference in New Issue
Block a user