Preferred method to make a polygon Transparent?

Aug 4, 2014 at 7:58 PM
Hey all. I need to make a polygon within an image have a border, but other than that be completely transparent. I've figured out a way to do this, but am not sure if there is an easier way:
// assume a 500x500 image in the variable layerImage
MagickColor tmpTransparent = new MagickColor(255, 255, 255);

List<Drawable> drawables = new List<Drawable>();
drawables.Add(new DrawableStrokeColor(Color.Black));
drawables.Add(new DrawableStrokeWidth(1));
drawables.Add(new DrawableFillColor(tmpTransparent));
drawables.Add(new DrawablePolygon( ... ); // <- polygon details left out

Essentially, fill the polygon with an unused color, then later use the .Transparent() method to make all pixels of that color "transparent". Is there a better way?

Aug 4, 2014 at 9:19 PM
I don't really understand why you don't make it transparent right away? If you didn't need the border and always have the same polygon you could use a clip mask. But I think this is the correct solution for your problem.
Aug 5, 2014 at 8:04 PM
Well, I was hoping to spare the details of where this exists in my process and isolate it as a single problem to solve ... what I am really doing is creating a series of polygons on top of a base map image. The polygons in this case represent Zip code boundaries, and are not simple single polygons, but rather collections of polygons, some of which are "inclusion" and some of which are "exclusion" (think of a donut). They are ordered correctly so that all "inclusions" are drawn first, then the "exclusions" are processed ... and my effort was essentially "how to make the contents of a polygon purely transparent".

The clip mask does sound interesting however. In theory, I could define the exclusion areas as "clip mask" areas, then draw the "inclusion polygons" followed by simply outlining the "exclusion" polygons in a line with no fill. I think I'll play with that for a while. Thanks for the input!