I want to mask a sprite, but I don't want to mask it in pure black(255,255,255). I know there's ways to change the masked color with 2d images, but I couldn't figure out how to do it with sprites. Any ideas? (thanks)
Spritemasks
Blitz3D Forums/Blitz3D Programming/Spritemasks Look at MaskImage in the docs
Let's say your prefered Mask Color is green, $00FF00, you would need to do the following:
(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.)
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.)
thanks