Cannot replace color

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Verlemion
Posts: 1
Joined: 2017-03-09T09:39:31-07:00
Authentication code: 1151

Cannot replace color

Post by Verlemion »

Hello, I'm trying to replace white color to green using this code:

Code: Select all

private static MagickImage ChangeWhiteColor(MagickImage Image, Color TargetColor)
        {
            MagickImage NewImage = new MagickImage(Image);

            NewImage.Opaque(MagickColor.FromRgb(255, (byte)255, (byte)255), 
                MagickColor.FromRgb(TargetColor.R,
                TargetColor.G,
                TargetColor.B));

            return NewImage;
        }
But it seems that code won't work, it just replaces color to light gray. What I should do?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Cannot replace color

Post by dlemstra »

Which version are you using? And what is the value of your TargetColor.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply