Converting mask to color

Aug 9, 2013 at 2:46 PM

I am unsuccessfully trying to give color to a mask. From the ImageMagick documentation I found there are a few ways to do this. How can I achieve any of the following with Magick.NET?
 convert heart_mask.gif  -background Red -alpha Shape  heart_red.png
 convert heart_mask.gif -negate  \
      -background Gold  -channel A  -combine   heart_gold.png
 convert heart_mask.gif \( +clone \) -alpha off \
      -compose CopyOpacity  -composite \
      -fill HotPink  -colorize 100%    heart_hotpink.png
Thank you for your time.
Aug 9, 2013 at 3:22 PM
Edited Aug 9, 2013 at 4:04 PM
Are you trying to give the transparency/alpha channel a color? You could use the ColorAlpha method for this.
Aug 9, 2013 at 4:13 PM
Edited Aug 9, 2013 at 6:21 PM
Yes. I'm basically trying to generate some of the jQuery UI icon images. The mask has a typical black background with the icons colored white, and I want to color the white icons blue let's say on a transparent background. Could you please give me a code snippet as well through which I can achieve this? I think I tried using ColorAlpha but it did not appear to work. Regardless, I'll try again.

Thank you for your prompt response.

Edit: No luck with ColorAlpha. Nothing happens.
Aug 9, 2013 at 6:29 PM
Can you post your image somewhere, so I can do some tests with it? I am now working on some changes for the next release and that includes adding the method LevelColors ( I think this is the method you are looking for.
Aug 9, 2013 at 6:40 PM
Sure. The image is:

Yes I read about the LevelColors method as well. I would be great if that were available. Thank you.
Aug 9, 2013 at 9:06 PM
I will add both Alpha and LevelColors. After the next release that I will publish this weekend you will be able to do this:
// Background purple, foreground yellow.
using (MagickImage image = new MagickImage("mask.png"))
  image.LevelColors(Color.Purple, Color.Yellow);

// Background transparent, foreground blue.
using (MagickImage image = new MagickImage("mask.png"))
  image.BackgroundColor = Color.Blue;
Aug 9, 2013 at 9:11 PM
That sounds great. Thank you very much.