Exemple #1
0
/**
 * Compute a RGB value with a specific format
 * \param fr, fg, fb Foreground RGB values [0-255].
 * \param br, bg, bb Background RGB values [0-255].
 * \param a Alpha value [0-255].
 * \param def_ordinal RGB format definition.
 * \return RGB nibble as ordinal value.
 */
adv_pixel pixel_merge_from_def(unsigned fr, unsigned fg, unsigned fb, unsigned br, unsigned bg, unsigned bb, unsigned char a, adv_color_def def_ordinal)
{
    return pixel_make_from_def(
               (fr*a + (255-a)*br) / 255,
               (fg*a + (255-a)*bg) / 255,
               (fb*a + (255-a)*bb) / 255,
               def_ordinal
           );
}
Exemple #2
0
static void ui_color_rgb_set(struct ui_color* color, const adv_color_rgb* c, adv_color_def color_def, adv_color_def buffer_def, unsigned translucency, adv_pixel* background)
{
	color->c = *c;
	color->p = pixel_make_from_def(c->red, c->green, c->blue, color_def);
	color->f = alpha_make_from_def(c->red, c->green, c->blue, 255, buffer_def);
	if (background)
		color->b = *background;
	else
		color->b = alpha_make_from_def(c->red, c->green, c->blue, translucency, buffer_def);
}
Exemple #3
0
/**
 * Compute a RGBA value with a specific format
 * \param r, g, b, a RGBA values [0-255].
 * \param def_ordinal RGBA format definition.
 * \return RGBA nibble as ordinal value.
 */
adv_pixel alpha_make_from_def(unsigned r, unsigned g, unsigned b, unsigned a, adv_color_def def_ordinal)
{
    int alpha_shift;
    adv_pixel alpha_mask;
    adv_pixel p;

    alpha_shiftmask_get(&alpha_shift, &alpha_mask, def_ordinal);

    return pixel_make_from_def(r, g, b, def_ordinal)
           | rgb_nibble_insert(a, alpha_shift, alpha_mask);
}