本文整理汇总了C#中ImageMagick.MagickImage.BrightnessContrast方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.BrightnessContrast方法的具体用法?C# MagickImage.BrightnessContrast怎么用?C# MagickImage.BrightnessContrast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.BrightnessContrast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
{
var conf = new EnhanceViewModel(configData);
dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");
using (MagickImage image = new MagickImage(infile))
{
if (conf.Normalize)
image.Normalize();
if (conf.AutoGamma)
image.AutoGamma();
image.BrightnessContrast(new Percentage(conf.Brightness), new Percentage(conf.Contrast));
if (conf.SContrast > 0)
image.SigmoidalContrast(true, conf.SContrast);
if (conf.Edge)
image.AdaptiveSharpen();
if (conf.Sharpen > 0)
image.UnsharpMask(1.5, 1.5, conf.Sharpen/100.0, 0.2);
image.Format = MagickFormat.Jpeg;
image.Write(dest);
}
return dest;
}
示例2: ExecuteBrightnessContrast
private void ExecuteBrightnessContrast(XmlElement element, MagickImage image)
{
Hashtable arguments = new Hashtable();
foreach (XmlAttribute attribute in element.Attributes)
{
if (attribute.Name == "brightness")
arguments["brightness"] = Variables.GetValue<Percentage>(attribute);
else if (attribute.Name == "channels")
arguments["channels"] = Variables.GetValue<Channels>(attribute);
else if (attribute.Name == "contrast")
arguments["contrast"] = Variables.GetValue<Percentage>(attribute);
}
if (OnlyContains(arguments, "brightness", "contrast"))
image.BrightnessContrast((Percentage)arguments["brightness"], (Percentage)arguments["contrast"]);
else if (OnlyContains(arguments, "brightness", "contrast", "channels"))
image.BrightnessContrast((Percentage)arguments["brightness"], (Percentage)arguments["contrast"], (Channels)arguments["channels"]);
else
throw new ArgumentException("Invalid argument combination for 'brightnessContrast', allowed combinations are: [brightness, contrast] [brightness, contrast, channels]");
}
示例3: OverrideTextureMaps
public bool OverrideTextureMaps(string textureName, double reflection, double blur, double specular) {
using (var image = new MagickImage(Kn5.TexturesData[textureName])) {
if (image.Width > 512 || image.Height > 512) {
image.Resize(512, 512);
}
image.BrightnessContrast(reflection, 1d, Channels.Red);
image.BrightnessContrast(blur, 1d, Channels.Green);
image.BrightnessContrast(specular, 1d, Channels.Blue);
return OverrideTexture(textureName, image.ToByteArray(MagickFormat.Bmp));
}
}
示例4: threshold
public static void threshold(string image_path, string output_path, int brightness = 20, int contrast = 20, int posterize = 2)
{
using (MagickImage image = new MagickImage(image_path)) {
image.BrightnessContrast(brightness, contrast);
image.ColorSpace = ColorSpace.Gray;
image.Posterize(posterize);
image.Normalize();
image.Write(output_path);
}
}
示例5: Test_BrightnessContrast
public void Test_BrightnessContrast()
{
using (MagickImage image = new MagickImage(Files.Builtin.Wizard))
{
ColorAssert.AreNotEqual(MagickColors.White, image, 340, 295);
image.BrightnessContrast(new Percentage(50), new Percentage(50));
image.Clamp();
ColorAssert.AreEqual(MagickColors.White, image, 340, 295);
}
}