Wednesday, 17 June 2009

Back to sprites

Here is something more that I was not aware of. Mode 4 sprites often have a mask. So what is the difference between an alpha channel and a mask. I thought an alpha channel gives 256 shades of transparency while a mask only says this bit of the image is visible and this bit is not. Wrong apparently. While writing a bit of code to save a mode 4 sprite with a mask I discovered this translation in the mask:

Image Pixel ---> Mask Pixel ---> Visible pixel
white ---> white ---> white
white ---> black ---> black
red ---> black ---> green
green ---> black ---> red
black ---> black ---> transparent

Only those bits of the image where both the visible and mask pixels are transparent.

No comments:

Post a Comment