How do I draw anti-aliased holes in a bitmap

Posted by gyozo kudor on Game Development See other posts from Game Development or by gyozo kudor
Published on 2011-06-05T16:15:50Z Indexed on 2012/03/27 11:40 UTC
Read the original article Hit count: 288

Filed under:
|
|

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):
What I have

And what I need is something like this (made with photoshop):
What I need

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.

© Game Development or respective owner

Related posts about c#

Related posts about .NET