Image Masking

Blitz3D Forums/Blitz3D Programming/Image Masking

RustyKristi(Posted 2016) [#1]
Probably been asked before but I was wondering how do you do those image masking things where you take a square image and apply a cutout image or alpha transparent as mask. Do I just use the command MaskImage?


steve_ancell(Posted 2016) [#2]
Just nominate a colour, usually magenta (255, 0, 255), and use MaskImage ;)


steve_ancell(Posted 2016) [#3]
I'm sure everyone quite possibly has their prefered way though.


RustyKristi(Posted 2016) [#4]
thanks steve, I'll post my results when I give this a try.


steve_ancell(Posted 2016) [#5]
Make sure the MaskImage parameters are set the same as the colour that you used to fill in the chosen transparent areas on your image, the colour picker tool in MS Paint will get the RGB values.


Matty(Posted 2016) [#6]
MaskImage ignores alpha...if you are talking about 2d in 3d with textures maskimage won't do it....you will have to manually set transparency of each pixel.


RustyKristi(Posted 2016) [#7]
Thanks Matty. I was really looking for something functional like a mini map with a masked shape other than square/rect. I thought this was the function I was looking for.

I would also like to know if there's a blitzmax 2d mod that can handle this, maybe freeimage?


steve_ancell(Posted 2016) [#8]
I forgot about lack of alpha control in 2D, thanks for the reminder Matty. ;)


Matty(Posted 2016) [#9]
If it is a small texture then simply writing each pixel alpha is potentially fast enough.


Kryzon(Posted 2016) [#10]
You can't do this with vanilla Blitz3D, but there's a texture combination mode that modulates the alpha from a texture layer with the alpha values of the texture layer below (essentially, the square texture would inherit the alpha from your soft transparency mask texture).

It was made available with Blitz3D with that FastExt library, but you can do this with BlitzMax since you can use API commands.