Extracting Alpha Bit from a texture

Blitz3D Forums/Blitz3D Beginners Area/Extracting Alpha Bit from a texture

Hi,

I've been working on something similar, and came up with the following :

;ARGB Functions by Rob Farley 2003
;rob@...
;http://www.mentalillusion.co.uk
;updated by Andrew Nixon Feb 2004 to include read and write alpha


Function read_r(x,y,image_name)
argb=ReadPixel(x,y,TextureBuffer(image_name))
Return (ARGB Shr 16) And $ff 
End Function

Function read_g(x,y,image_name)
argb=ReadPixel(x,y,TextureBuffer(image_name))
Return (ARGB Shr 8) And $ff 
End Function

Function read_b(x,y,image_name)
argb=ReadPixel(x,y,TextureBuffer(image_name))
Return ARGB And $ff
End Function

Function read_a(x,y,image_name)
argb=ReadPixel(x,y,TextureBuffer(image_name))
Return (ARGB Shr 24)  And $ff
End Function


Function write_argb(x,y,a,r,g,b,image_name)
argb=(b Or (g Shl 8) Or (r Shl 16) Or (a Shl 24))
WritePixel x,y,argb,TextureBuffer(image_name)
End Function


Hope this helps,


Cheers,


Unc