本文整理汇总了C#中MagickImage类的典型用法代码示例。如果您正苦于以下问题:C# MagickImage类的具体用法?C# MagickImage怎么用?C# MagickImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MagickImage类属于命名空间,在下文中一共展示了MagickImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ClipPath
public ClipPath(string name, int width, int height)
{
// ImageInfo info = new ImageInfo();
// info.setBackgroundColor(new PixelPacket(255,255,255,0));
this.name = name;
this.image = new MagickImage(width, height/*, info*/);
}
开发者ID:jondot,项目名称:nmagick,代码行数:7,代码来源:ClipPath.cs
示例2: Pattern
public Pattern(string name, int x, int y, int width, int height)
{
this.name = name;
this.x = x;
this.y = y;
this.image = new MagickImage(width, height);
}
开发者ID:jondot,项目名称:nmagick,代码行数:7,代码来源:Pattern.cs
示例3: Test_Log
public void Test_Log()
{
using (MagickImage image = new MagickImage(Files.SnakewarePNG))
{
int count = 0;
EventHandler<LogEventArgs> logDelegate = delegate(object sender, LogEventArgs arguments)
{
Assert.IsNull(sender);
Assert.IsNotNull(arguments);
Assert.AreNotEqual(ExceptionTypes.Undefined, arguments.EventType);
Assert.IsNotNull(arguments.Message);
Assert.AreNotEqual(0, arguments.Message.Length);
count++;
};
GraphicsMagickNET.Log += logDelegate;
image.Flip();
Assert.AreEqual(0, count);
GraphicsMagickNET.SetLogEvents(ExceptionTypes.All);
image.Flip();
Assert.AreNotEqual(0, count);
GraphicsMagickNET.Log -= logDelegate;
count = 0;
image.Flip();
Assert.AreEqual(0, count);
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:33,代码来源:GraphicsMagickNETTests.cs
示例4: Test_ToBitmap
//===========================================================================================
private static void Test_ToBitmap(MagickImage image, ImageFormat format)
{
using (Bitmap bmp = image.ToBitmap(format))
{
Assert.AreEqual(format, bmp.RawFormat);
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:MagickImageTests.cs
示例5: Test_Pixel
//===========================================================================================
private static void Test_Pixel(MagickImage image, int x, int y, MagickColor color)
{
using (PixelCollection collection = image.GetReadOnlyPixels())
{
ColorAssert.AreEqual(color, collection.GetPixel(x, y));
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:MagickImageTests.cs
示例6: Test_FromIXPathNavigable
public void Test_FromIXPathNavigable()
{
using (MagickImage image = new MagickImage(Files.InvitationTif))
{
XmpProfile profile = image.GetXmpProfile();
Assert.IsNotNull(profile);
IXPathNavigable doc = profile.ToIXPathNavigable();
ExceptionAssert.Throws<ArgumentNullException>(delegate()
{
XmpProfile.FromIXPathNavigable(null);
});
XmpProfile newProfile = XmpProfile.FromIXPathNavigable(doc);
image.AddProfile(newProfile);
doc = profile.ToIXPathNavigable();
TestIXPathNavigable(doc);
profile = image.GetXmpProfile();
Assert.IsNotNull(profile);
doc = profile.ToIXPathNavigable();
TestIXPathNavigable(doc);
Assert.AreEqual(profile, newProfile);
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:29,代码来源:XmpProfileTests.cs
示例7: Test_Constructor
public void Test_Constructor()
{
using (MemoryStream memStream = new MemoryStream())
{
using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNull(profile);
profile = new ExifProfile();
profile.SetValue(ExifTag.Copyright, "Dirk Lemstra");
image.AddProfile(profile);
profile = image.GetExifProfile();
Assert.IsNotNull(profile);
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
Assert.AreEqual(1, profile.Values.Count());
ExifValue value = profile.Values.FirstOrDefault(val => val.Tag == ExifTag.Copyright);
TestValue(value, "Dirk Lemstra");
}
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:33,代码来源:ExifProfileTests.cs
示例8: CheckTransparency
private static void CheckTransparency(MagickImage image)
{
if (!image.HasAlpha)
return;
if (image.IsOpaque)
image.HasAlpha = false;
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:8,代码来源:PngOptimizer.cs
示例9: GetIptcValue
//===========================================================================================
private static IptcValue GetIptcValue()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
IptcProfile profile = image.GetIptcProfile();
return profile.Values.ElementAt(1);
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:9,代码来源:IptcValueTests.cs
示例10: Test_IEnumerable
public void Test_IEnumerable()
{
using (MagickImage image = new MagickImage(Color.Red, 5, 10))
{
PixelCollection pixels = image.GetReadOnlyPixels();
Assert.AreEqual(50, pixels.Count());
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:PixelCollectionTests.cs
示例11: Get8BimValue
//===========================================================================================
private static EightBimValue Get8BimValue()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
EightBimProfile profile = image.Get8BimProfile();
return profile.Values.First();
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:9,代码来源:EightBimValueTests.cs
示例12: Test_Set
public void Test_Set()
{
using (MagickImage image = new MagickImage(Color.Red, 5, 10))
{
using (WritablePixelCollection pixels = image.GetWritablePixels())
{
ExceptionAssert.Throws<ArgumentNullException>(delegate()
{
pixels.Set((QuantumType[])null);
});
ExceptionAssert.Throws<ArgumentNullException>(delegate()
{
pixels.Set((Pixel)null);
});
ExceptionAssert.Throws<ArgumentNullException>(delegate()
{
pixels.Set((Pixel[])null);
});
Test_Set(pixels, new QuantumType[] { });
Test_Set(pixels, new QuantumType[] { 0 });
Test_Set(pixels, new QuantumType[] { 0, 0 });
Test_Set(pixels, new QuantumType[] { 0, 0, 0 });
pixels.Set(new QuantumType[] { 0, 0, 0, 0, 0 });
Test_PixelColor(pixels, Color.Black);
pixels.Write();
}
using (PixelCollection pixels = image.GetReadOnlyPixels())
{
Test_PixelColor(pixels, Color.Black);
}
using (WritablePixelCollection pixels = image.GetWritablePixels())
{
pixels.Set(new uint[] { 4294967295, 0, 0, 0, 0 });
Test_PixelColor(pixels, Color.Red);
pixels.Set(new ushort[] { 0, 0, 65535, 0, 0 });
Test_PixelColor(pixels, Color.Blue);
pixels.Set(new byte[] { 0, 255, 0, 0, 0 });
Test_PixelColor(pixels, Color.Lime);
}
using (WritablePixelCollection pixels = image.GetWritablePixels())
{
for (int x = 0; x < pixels.Width; x++)
{
for (int y = 0; y < pixels.Height; y++)
{
pixels.Set(x, y, new QuantumType[] { 0, 0, 0, 0, 0 });
}
}
}
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:58,代码来源:WritablePixelCollectionTests.cs
示例13: DrawableComposite
/// <summary>
/// Initializes a new instance of the <see cref="DrawableComposite"/> class.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <param name="y">The Y coordinate.</param>
/// <param name="image">The image to draw.</param>
public DrawableComposite(double x, double y, MagickImage image)
: this(image)
{
X = x;
Y = y;
Width = _Image.Width;
Height = _Image.Height;
Compose = CompositeOperator.CopyAlpha;
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:DrawableComposite.cs
示例14: Test_Clone
//===========================================================================================
private static void Test_Clone(MagickImage first, MagickImage second)
{
Assert.AreEqual(first, second);
second.Format = MagickFormat.Jp2;
Assert.AreEqual(first.Format, MagickFormat.Png);
Assert.AreEqual(second.Format, MagickFormat.Jp2);
second.Dispose();
Assert.AreEqual(first.Format, MagickFormat.Png);
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:10,代码来源:MagickImageTests.cs
示例15: GetExifValue
//===========================================================================================
private static ExifValue GetExifValue()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
return profile.Values.First();
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:11,代码来源:ExifValueTests.cs
示例16: Test_GetValue
public void Test_GetValue()
{
using (MagickImage image = new MagickImage(Color.Red, 5, 10))
{
using (WritablePixelCollection pixels = image.GetWritablePixels())
{
Test_PixelColor(pixels, Color.Red);
}
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:10,代码来源:WritablePixelCollectionTests.cs
示例17: Test_ICM
public void Test_ICM()
{
using (MagickImage image = new MagickImage(Files.SnakewarePNG))
{
ColorProfile profile = image.GetColorProfile();
Assert.IsNull(profile);
image.AddProfile(new ImageProfile("icm", ColorProfile.SRGB.ToByteArray()));
TestProfile(image.GetColorProfile(), "icc");
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:11,代码来源:ColorProfileTests.cs
示例18: Test_Dimensions
public void Test_Dimensions()
{
using (MagickImage image = new MagickImage(Color.Red, 5, 10))
{
using (WritablePixelCollection pixels = image.GetWritablePixels())
{
Assert.AreEqual(5, pixels.Width);
Assert.AreEqual(10, pixels.Height);
Assert.AreEqual(5 * 10 * 5, pixels.GetValues().Length);
}
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:12,代码来源:WritablePixelCollectionTests.cs
示例19: Test_Attribute
public void Test_Attribute()
{
using (MagickImage image = new MagickImage(Files.SnakewarePNG))
{
Assert.IsNull(image.GetAttribute("test"));
image.SetAttribute("test", "");
Assert.AreEqual(null, image.GetAttribute("test"));
image.SetAttribute("test", "123");
Assert.AreEqual("123", image.GetAttribute("test"));
}
}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:13,代码来源:MagickImageTests.cs
示例20: MakeCards
public void MakeCards()
{
var deck = JsonConvert.DeserializeObject<Deck>(File.ReadAllText(@"C:\temp\testdeck.cm"));
var cards = new List<MagickImage>();
foreach (var card in deck.Cards) {
var image = new MagickImage(new MagickColor("WhiteSmoke"), deck.Width, deck.Height);
image.Density = new MagickGeometry(300, 300);
image.Format = MagickFormat.Bmp;
foreach (var element in deck.Elements) {
var data = card.ElementData[element.Key];
if (File.Exists(data)) {
using (var overlayImage = new MagickImage(data)) {
image.Composite(overlayImage, (int)element.Value.X, (int)element.Value.Y, CompositeOperator.Over);
}
} else {
using (var textImage = new MagickImage(MagickColor.Transparent, deck.Width, deck.Height)) {
textImage.Density = new MagickGeometry(300, 300);
textImage.Font = "Arial";
textImage.FontPointsize = 12;
textImage.FillColor = new MagickColor("Black");
var drawableText = new DrawableText(element.Value.X, element.Value.Y, data);
textImage.Draw(drawableText);
image.Composite(textImage, CompositeOperator.Over);
}
}
}
image.Write(string.Format(@"c:\temp\CardMaker\{0}.png", card.Name));
cards.Add(image);
}
using (var doc = new Document()) {
PdfWriter.GetInstance(doc, new FileStream(@"C:\temp\CardMaker\cards.pdf", FileMode.Create));
doc.Open();
var columns = (int)Math.Floor(doc.PageSize.Width / (deck.Width + 10));
var table = new PdfPTable(columns) { WidthPercentage = 100, DefaultCell = { Border = 0, Padding = 5 } };
foreach (var card in cards) {
var instance = Image.GetInstance(card.ToByteArray());
instance.SetDpi(300, 300);
var cell = new PdfPCell(instance) {
HorizontalAlignment = Element.ALIGN_CENTER,
Border = 0,
Padding = 5,
};
table.AddCell(cell);
}
table.CompleteRow();
doc.Add(table);
}
}
开发者ID:camwheeler,项目名称:CardMaker,代码行数:51,代码来源:CardGenerator.cs
注:本文中的MagickImage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论