C# 我想看一点一点地画
我要从表格转到WPF,我有个问题。我正在通过调用(用于)此方法将(10000)坐标XY绘制到画布:C# 我想看一点一点地画,c#,wpf,C#,Wpf,我要从表格转到WPF,我有个问题。我正在通过调用(用于)此方法将(10000)坐标XY绘制到画布: private void AddPixel(double x, double y, int color) { Rectangle rec = new Rectangle(); Canvas.SetTop(rec, y); Canvas.SetLeft(rec, x); rec.Width = 1; rec.H
private void AddPixel(double x, double y, int color)
{
Rectangle rec = new Rectangle();
Canvas.SetTop(rec, y);
Canvas.SetLeft(rec, x);
rec.Width = 1;
rec.Height = 1;
if (color == 1)
{
rec.Fill = new SolidColorBrush(Colors.Black);
}
if (color == 2)
{
rec.Fill = new SolidColorBrush(Colors.Red);
}
myCanvas.Children.Add(rec);
}
现在,点在背景上绘制,渲染点后,窗口将显示完成的解决方案。
我想看到的是,实时绘制点,类似于“动画”和新坐标。(对不起我的英语)你可以使用定时器,每次定时器关闭时添加一定数量的点。理论上,你可以一次创建10000(hic!)帧的动画,让WPF播放。你也可以使用故事板来设置属性的动画。如果你想在WPF中快速渲染,你应该使用GDI+渲染。使用
InteropBitmap
查找示例。通过CreateFileMapping
,MapViewOfFile
,Imaging.CreateBitmapSourceFromMemorySection
,GetGdiGraphics
<代码>冻结WPF图像
控件的InteropBitmap
并强制转换为BitmapSource
。