Let's say your prefered Mask Color is green, $00FF00, you would need to do the following:
sprite=createsprite()
tex=loadtexture("tex.bmp",4)
entitytexture sprite,tex
setbuffer texturebuffer(tex)
lockbuffer()
for j=0 to textureheight(tex)-1
for i=0 to texturewidth(tex)-1
rgb=readpixelfast(i,j) and $FFFFFF
if rgb=$00FF00 then
al=$0
else
al=$FF000000
endif
writepixelfast i,j,(rgb or al)
next
next
unlockbuffer()
setbuffer backbuffer()
(Note: in 16 Bit Color Resolution this might not work properly, you maybe need to convert $00FF00 to its 16-Bit Equivalent and compare this result. I think you can easily convert it by writing $00FF00 to a texture in 16 Bit mode, and then read that texel - someone correct me if I'm wrong.)
|