#44546 - telamon - Thu Jun 02, 2005 7:56 pm
Hi! I've kindof become stuck. I wrote this color blending routine, but it's spitting out completely wrong values. I've spent much about the whole day figureing out why it won't work but have had no sucess. :(
If anyone of you could help me getting this to work, i'd be extremely grateful.
_________________
http://manifested.ath.cx
If anyone of you could help me getting this to work, i'd be extremely grateful.
Code: |
u16 Blend_Normal(u16 c1,u16 c2,u8 a){ // input: Color 1 , Color 2 , Alpha value. // 32 blending levels #define MAXBIT 5 #define MAX (1<<(MAXBIT)) /* u16 0 00000 00000 00000 B G R */ if(c1 == Transparent_Color) c1 = Canvas_Color; if(c2 == Transparent_Color) return Transparent_Color; u8 rgb[3],i; for(i=0;i<3;i++){ rgb[i]=( ((c1<<(i*5+1))>>11)*(MAX-a) + ((c2<<(i*5+1))>>11)*a )>>MAXBIT; } return RGB15(rgb[2],rgb[1],rgb[0]); } |
_________________
http://manifested.ath.cx