fastest way to do an inverse mask

Jan 8, 2011 at 1:42 PM


What is the fastest way to do an inverse mask?  I can blit using the mask option and get only the masked off region of the bitmap, but what I want is the inverse, i.e. only the region that isn't masked off.  At the moment I am just cycling through all the pixels one-by-one and changing the mask color to transaparent and the rest to the mask color.  This works but it's probably the slowest way of doing it.

Jan 8, 2011 at 8:22 PM

The quickest solution would be if you take the source code of the Blit method, look at the Mask branch in the Blit method and a new branch where you perform the inverse mask directly. Or maybe you can change the bitmaps you are using.


- Rene

Jan 9, 2011 at 6:20 PM



thank you, easier than I thought:

else if

(BlendMode == BlendMode.MaskInvert)


sa = sa == 0 ? 255 : 0;