本文整理汇总了C#中MagickImage.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Draw方法的具体用法?C# MagickImage.Draw怎么用?C# MagickImage.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagickImage
的用法示例。
在下文中一共展示了MagickImage.Draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: Test_Drawable
public void Test_Drawable()
{
using (MagickImage image = new MagickImage(Color.Red, 10, 10))
{
MagickColor yellow = Color.Yellow;
image.Draw(new DrawableFillColor(yellow), new DrawableRectangle(0, 0, 10, 10));
Test_Pixel(image, 5, 5, yellow);
}
}