本文整理汇总了C#中System.Windows.Media.Imaging.RenderTargetBitmap.GetPixels方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTargetBitmap.GetPixels方法的具体用法?C# RenderTargetBitmap.GetPixels怎么用?C# RenderTargetBitmap.GetPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.RenderTargetBitmap
的用法示例。
在下文中一共展示了RenderTargetBitmap.GetPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
void Render(int points, int size)
{
var sw = Stopwatch.StartNew();
var r = new Random();
var pen = new Pen(Brushes.DeepPink, 2);
pen.Freeze();
Trace.WriteLine("after freeze: " + sw.GetElapsedAndRestart().TotalMilliseconds);
var d = new DrawingGroup();
using (var cx = d.Open())
{
for (int i = 0; i < points; i++)
{
cx.DrawLine(pen, new Point(r.Next(0, 50), r.Next(0, 50)), new Point(r.Next(0, 50), r.Next(0, 50)));
}
}
d.Freeze();
var dv = new DrawingVisual();
using (var cx = dv.RenderOpen())
{
cx.DrawDrawing(d);
//for (int i = 0; i < points; i++)
//{
// cx.DrawLine(pen, new Point(r.Next(0, 50), r.Next(0, 50)), new Point(r.Next(0, 50), r.Next(0, 50)));
//}
}
Trace.WriteLine("after draw: " + sw.GetElapsedAndRestart().TotalMilliseconds);
var trb = new RenderTargetBitmap(size, size, 96, 96, PixelFormats.Pbgra32);
trb.Render(dv);
Trace.WriteLine("after render: " + sw.GetElapsedAndRestart().TotalMilliseconds);
var x = trb.GetPixels();
Trace.WriteLine("after get pixels: " + sw.GetElapsedAndRestart().TotalMilliseconds);
//trb.Save([email protected]"C:\temp\shit\{size}.png");
}