我在我的应用程序中有一个问题(WinForms我希望它不是一个问题,因为下面的链接是指WPF),我的所有问题都是这样描述的:
为了显示大量的视频流,我过去经常使用画框,而不是意识到绘图非常慢,并且fps变得更低。
我听取了与Direct3D11合作的人的建议,但我在评审员中遇到了一个问题:
Texture2D tex = new Texture2D(Device, texDesc);
我怎样才能发送设备?设备是一个类型而不是一个对象,它弹出一个错误给我,我和SlimDX ofc一起工作,Direct3D11真的想弄清楚怎么做,还是创建我自己的设备?如果有其他方法来优化FPS和绘图,或者任何人创建了一个可以处理这个问题的控件,我也可以通过邮件与我联系: dorbenshimon1{at}gmail{dot}com,非常感谢。
发布于 2015-01-13 13:47:35
您已经回答了您自己的问题--您需要传递您创建的设备实例,而不是类型。
请查看设置视口的示例,以了解这是如何完成的。
根据注释,如果您只想快速粘贴图像,那么DirectX几乎肯定不是正确的工具。试一试类似于此的方法:
using System.Windows.Forms;
public class FastImageRedraw : Panel
{
private Image image;
public FastImageRedraw()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.UpdateStyles();
}
public Image Image
{
get { return this.image; }
set
{
this.image = value;
this.Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(this.Image, e.ClipRectangle);
}
}
这是非常基本的,但只有在更改图像时才使用GDI+处理重绘。
使用var fastImage = new FastImageRedraw();
作为标准创建它的一个实例
然后,每当图像发生fastImage.Image = myImage;
更改时,就更新它。
https://stackoverflow.com/questions/27923565
复制相似问题