blend.c 431 Bytes

#include "graphic.h"

do_blend( alf, new, old, res)
int alf, new, old, *res;
{
int nr, ng, nb, na;
int or, og, ob;

	unpack_colora( new, nr, ng, nb, na);
	unpack_color( old, or, og, ob);
	alf = times_alpha( na, alf);
/* saturate */
	or += times_alpha( nr, alf);
	og += times_alpha( ng, alf);
	ob += times_alpha( nb, alf);
	or = clamp_color( or);
	og = clamp_color( ob);
	ob = clamp_color( og);
	*res = pack_color( or, og, ob);
	}