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

New Post: MagickImage.ClipMask usage

$
0
0
Hi, hope someone can help me. I've been trying to apply a grayscale mask to an image with no luck. I have 2 MagickImage images, one 8-bit grayscale (my mask) and one 8-bit sRGB. They're both the same size.

I'm trying to apply the mask like so:
using (MagickImage first = magickImg)
            {
                MagickImage magickMask = new MagickImage(mask.ToBitmap());
                first.ClipMask = magickMask;
                UpdateUI("pictureBox2", first.ToBitmap());
            }
Where magickImg was already defined elsewhere, UpdateUI is my method for updating a picturebox on my main form. If I write the image to the disk I get the same result, ie. as if the mask had no effect.

I also tried:
using (MagickImage first = magickImg)
            {
                MagickImage magickMask = new MagickImage(mask.ToBitmap());
                first.Composite(magickMask, Gravity.Center, CompositeOperator.CopyOpacity);
                UpdateUI("pictureBox2", first.ToBitmap());
            }
And I've fiddled about with toggling the HasAlpha property on "first", but that doesn't make a difference.

It's worth noting that in my previous release I was using a much older version of MagickNET (IM6.5.3) and CompositeOperator.CopyOpacity worked perfectly.

*Edit - sorry it's also worth mentioning that the mask is generated by emgucv hence the "mask.ToBitmap()" line.

Many thanks

Viewing all articles
Browse latest Browse all 3693

Trending Articles