How do I draw anti-aliased holes in a bitmap
- by gyozo kudor
I have an artillery game (hobby-learning project) and when the projectile hits it leaves a hole in the ground. I want this hole to have antialiased edges. I'm using System.Drawing for this. I've tried with clipping paths, and drawing with a transparent color using gfx.CompositingMode = CompositingMode.SourceCopy, but it gives me the same result. If I draw a circle with a solid color it works fine, but I need a hole, a circle with 0 alpha values.
I have enabled these but they work only with solid colors:
gfx.CompositingQuality = CompositingQuality.HighQuality;
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
gfx.SmoothingMode = SmoothingMode.AntiAlias;
In the two pictures consider black as being transparent.
This is what I have (zoomed in):
And what I need is something like this (made with photoshop):
This will be just a visual effect, in code for collision detection I still treat everything with alpha 128 as solid.
Edit: I'm usink OpenTK for this game. But for this question I think it doesn't really matter probably it is gdi+ related.