Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Preferred method to make a polygon Transparent?

$
0
0
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

layerImage.Draw(drawables);
layerImage.Transparent(tmpTransparent);
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?

thanks,
-kh

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>