ImageMagick.MagickScript.ExecuteWhiteThreshold C# (CSharp) Method

ExecuteWhiteThreshold() private method

private ExecuteWhiteThreshold ( XmlElement element, MagickImage image ) : void
element XmlElement
image MagickImage
return void
    private void ExecuteWhiteThreshold(XmlElement element, MagickImage image)
    {
      Hashtable arguments = new Hashtable();
      foreach (XmlAttribute attribute in element.Attributes)
      {
        if (attribute.Name == "channels")
          arguments["channels"] = Variables.GetValue<Channels>(attribute);
        else if (attribute.Name == "threshold")
          arguments["threshold"] = Variables.GetValue<Percentage>(attribute);
      }
      if (OnlyContains(arguments, "threshold"))
        image.WhiteThreshold((Percentage)arguments["threshold"]);
      else if (OnlyContains(arguments, "threshold", "channels"))
        image.WhiteThreshold((Percentage)arguments["threshold"], (Channels)arguments["channels"]);
      else
        throw new ArgumentException("Invalid argument combination for 'whiteThreshold', allowed combinations are: [threshold] [threshold, channels]");
    }
  }
MagickScript