本文整理汇总了C#中ImageMagick.MagickImageCollection.Map方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImageCollection.Map方法的具体用法?C# MagickImageCollection.Map怎么用?C# MagickImageCollection.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImageCollection
的用法示例。
在下文中一共展示了MagickImageCollection.Map方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Map
public void Test_Map()
{
using (MagickImageCollection colors = new MagickImageCollection())
{
colors.Add(new MagickImage(MagickColors.Red, 1, 1));
colors.Add(new MagickImage(MagickColors.Green, 1, 1));
using (MagickImage remapImage = colors.AppendHorizontally())
{
using (MagickImageCollection collection = new MagickImageCollection())
{
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection.Map(null);
});
ExceptionAssert.Throws<InvalidOperationException>(delegate ()
{
collection.Map(remapImage);
});
collection.Read(Files.RoseSparkleGIF);
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
collection.Map(null);
});
QuantizeSettings settings = new QuantizeSettings();
settings.DitherMethod = DitherMethod.FloydSteinberg;
collection.Map(remapImage, settings);
ColorAssert.AreEqual(MagickColors.Red, collection[0], 60, 17);
ColorAssert.AreEqual(MagickColors.Green, collection[0], 37, 24);
ColorAssert.AreEqual(MagickColors.Red, collection[1], 58, 30);
ColorAssert.AreEqual(MagickColors.Green, collection[1], 36, 26);
ColorAssert.AreEqual(MagickColors.Red, collection[2], 60, 40);
ColorAssert.AreEqual(MagickColors.Green, collection[2], 17, 21);
}
}
}
}
示例2: ExecuteMap
private MagickImage ExecuteMap(XmlElement element, MagickImageCollection collection)
{
Hashtable arguments = new Hashtable();
foreach (XmlElement elem in element.SelectNodes("*"))
{
arguments[elem.Name] = CreateQuantizeSettings(elem);
}
if (arguments.Count == 0)
{
collection.Map();
return null;
}
else if (OnlyContains(arguments, "settings"))
{
collection.Map((QuantizeSettings)arguments["settings"]);
return null;
}
else
throw new ArgumentException("Invalid argument combination for 'map', allowed combinations are: [] [settings]");
}