Read/WritePixelFast

Blitz3D Forums/Blitz3D Beginners Area/Read/WritePixelFast

_PJ_(Posted 2010) [#1]
How can I remove any transparency (alpha) from the ARGB values returned by ReadPixelFast or used by WritePixelFast?

For Example:

What would I need for rgb in the code below?

Dim pix(GraphicsWidth(),GraphicsHeight()) 
LockBuffer 
For y=0 To GraphicsHeight() 
For x=0 To GraphicsWidth() 
argb=ReadPixelFast(x,y) 
;rgb=argb Shr ????????????????????????????????
pix(x,y)=rgb
Next 
Next 
UnlockBuffer 



Yasha(Posted 2010) [#2]
rgb = argb Or $FF000000    ;Set the alpha to 1
rgb = argb And $00FFFFFF    ;Set the alpha to 0



_PJ_(Posted 2010) [#3]
Thanks very much, Yasha, just to check though: Setting Alpha to 1 is opaque, as with 3D, right?


GIB3D(Posted 2010) [#4]
Yes


Ross C(Posted 2010) [#5]
I have handy functions in my code archive entries for removing or inserting alpha or masking also based on colour if it helps?


_PJ_(Posted 2010) [#6]
Ah thanks Ross, no worries, though Ive sorted it now. Incidentally, I did try a search and looking through the archives, but I don't think I found them - Maybe I just didn't know really what I was looking for!


cryptadone(Posted 2014) [#7]
or:

a=argb shr 24

argb=(a shl 24)+(r shl 16)+(g shl 8)+b

...