Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Stonemonkey on June 17, 2006

Title: fairly quick alpha thingy
Post by: Stonemonkey on June 17, 2006
Here's a little #define alpha thing, give it a source and destination and it takes the alpha component ot the source to blend with the destination value



#define alpha(s,d) ((((s and &hff00ff)*(s shr 24)+(d and &hff00ff)*(256-(s shr 24)))and &hff00ff00)or(((s and &hff00)*(s shr 24)+(d and &hff00)*(256-(s shr 24)))and &hff0000))shr 8





'if an array is used for the screen
screen(pixel)=alpha(argb_source,screen(pixel))

'or if using pointers
*pixel_pointer=alpha(argb_source,*pixel_pointer)

'or can just be used on individual variables
argb_out=alpha(argb0_in,argb1_in)


Title: Re: fairly quick alpha thingy
Post by: Shockwave on June 17, 2006
Nice one Fryer :) Thanks.
Title: Re: fairly quick alpha thingy
Post by: Stonemonkey on June 17, 2006
No problem Shockwave, I think it should be pretty quick. Let me know if it's any use or if there's any problems or if there's any other types of blending you can think of.