如何在MagickImage中使用-highlight-color?

时间:2017-11-10 11:29:36

标签: imagemagick

SetLowlightColor不起作用!

 using (IMagickImage img1 = new MagickImage(Path.Combine(fullpath, IMAGE1)))
        {
            using (IMagickImage img2 = new MagickImage(Path.Combine(fullpath, IMAGE2)))
            {
                using (IMagickImage imgDiff = new MagickImage())
                {
                    img1.ColorFuzz = new Percentage(fuzz);                       
                    imgDiff.SetLowlightColor(new MagickColor(Color.Blue)); 
                    double diff = img1.Compare(img2, ErrorMetric.Absolute, imgDiff);


                    imgDiff.Write(result);
                }
            }
        }

https://www.imagemagick.org/Usage/compare/

1 个答案:

答案 0 :(得分:0)

您似乎在Magick.NET库中发现了一个错误。我刚刚发布了该库的7.1.0.0版来解决您的问题。但我还决定从SetLowlightColor类移动MagickImage并引入一个名为CompareSettings的新类,您可以在其中设置Lowlightcolor。移动此属性是因为它仅由compare方法使用。您的代码应更改为:

using (IMagickImage img1 = new MagickImage(Path.Combine(fullpath, IMAGE1)))
{
    using (IMagickImage img2 = new MagickImage(Path.Combine(fullpath, IMAGE2)))
    {
        using (IMagickImage imgDiff = new MagickImage())
        {
            img1.ColorFuzz = new Percentage(fuzz);
            CompareSettings settings = new CompareSettings()
            {
                Metric = ErrorMetric.Absolute,
                LowlightColor = MagickColors.Blue
            };
            double diff = img1.Compare(img2, settings, imgDiff);

            imgDiff.Write(result);
        }
    }
}