本文整理汇总了C#中ImageMagick.MagickImage.ColorAlpha方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.ColorAlpha方法的具体用法?C# MagickImage.ColorAlpha怎么用?C# MagickImage.ColorAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.ColorAlpha方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_RemoveAlpha
public void Test_RemoveAlpha()
{
string tempFile = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png";
try
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
Assert.IsTrue(image.HasAlpha);
image.ColorAlpha(new MagickColor("yellow"));
image.HasAlpha = true;
image.Write(tempFile);
image.Read(tempFile);
// TODO: Figure out why this does not fail in a single run but does when all tests are run.
//Assert.IsTrue(image.HasAlpha);
PngOptimizer optimizer = new PngOptimizer();
optimizer.LosslessCompress(tempFile);
image.Read(tempFile);
Assert.IsFalse(image.HasAlpha);
}
}
finally
{
if (File.Exists(tempFile))
File.Delete(tempFile);
}
}
示例2: Test_RemoveAlpha
public void Test_RemoveAlpha()
{
string tempFile = GetTemporaryFileName(".png");
try
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
Assert.IsTrue(image.HasAlpha);
image.ColorAlpha(new MagickColor("yellow"));
image.HasAlpha = true;
image.Write(tempFile);
image.Read(tempFile);
Assert.IsTrue(image.HasAlpha);
PngOptimizer optimizer = new PngOptimizer();
optimizer.LosslessCompress(tempFile);
image.Read(tempFile);
Assert.IsFalse(image.HasAlpha);
}
}
finally
{
File.Delete(tempFile);
}
}
示例3: ExecuteColorAlpha
private void ExecuteColorAlpha(XmlElement element, MagickImage image)
{
MagickColor color_ = Variables.GetValue<MagickColor>(element, "color");
image.ColorAlpha(color_);
}
示例4: Test_IsOpaque
public void Test_IsOpaque()
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
Assert.IsFalse(image.IsOpaque);
image.ColorAlpha(Color.Purple);
Assert.IsTrue(image.IsOpaque);
}
using (MagickImage image = new MagickImage(Files.Builtin.Logo))
{
Assert.IsTrue(image.IsOpaque);
image.Opaque(Color.White, MagickColor.Transparent);
Assert.IsFalse(image.IsOpaque);
}
}
示例5: Test_ColorAlpha
public void Test_ColorAlpha()
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
MagickColor purple = new MagickColor("purple");
image.ColorAlpha(purple);
using (PixelCollection pixels = image.GetReadOnlyPixels())
{
ColorAssert.AreNotEqual(purple, pixels.GetPixel(45, 75).ToColor());
ColorAssert.AreEqual(purple, pixels.GetPixel(100, 60).ToColor());
}
}
}
示例6: Test_ColorAlpha
public void Test_ColorAlpha()
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
MagickColor purple = new MagickColor("purple");
image.ColorAlpha(purple);
ColorAssert.AreNotEqual(purple, image, 45, 75);
ColorAssert.AreEqual(purple, image, 100, 60);
}
}