Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 视频捕获/屏幕截图_C#_Slimdx - Fatal编程技术网

C# 视频捕获/屏幕截图

C# 视频捕获/屏幕截图,c#,slimdx,C#,Slimdx,我尝试流式处理我的桌面,问题是我使用GDI时有8/10 fps,使用SlimDX时有1 fps GDI 夏普DX PresentParameters present_params = new PresentParameters(); present_params.Windowed = true; present_params.SwapEffect = SwapEffect.Discard; present_params.BackBufferCount = 1; present_params.Fu

我尝试流式处理我的桌面,问题是我使用GDI时有8/10 fps,使用SlimDX时有1 fps

GDI

夏普DX

PresentParameters present_params = new PresentParameters();
present_params.Windowed = true;
present_params.SwapEffect = SwapEffect.Discard;
present_params.BackBufferCount = 1;
present_params.FullScreenRefreshRateInHertz = 0;
Device d = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, present_params);

Surface s = Surface.CreateOffscreenPlain(d, 1680, 1050, Format.A8R8G8B8, Pool.Scratch);

d.GetFrontBufferData(0, s);

bmp = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(s, SlimDX.Direct3D9.ImageFileFormat.Bmp));
而且…我需要在位图中备份曲面。
提前感谢

不确定你的问题是什么。如何获得更好的性能?你做了什么样的测试来确定问题的原因?您是否尝试过重新采样位图以降低bpp?您是否尝试过剪裁屏幕的较小区域以查看性能是否有所提高?是否尝试过重用位图?在我看来,您正在为每个帧分配一个新位图(在该分辨率下,每个位图大约有7MB内存)。这将是难以置信的慢…没办法。你有没有试着重用位图?是的,它不会改变。您是否尝试过重新采样位图以降低bpp?是的,640*480有60帧每秒,我有30帧每秒,1680*1050有位图,640*480有CopyFromScreen。我忘了说我发送udp数据(所以我序列化了位图)。
PresentParameters present_params = new PresentParameters();
present_params.Windowed = true;
present_params.SwapEffect = SwapEffect.Discard;
present_params.BackBufferCount = 1;
present_params.FullScreenRefreshRateInHertz = 0;
Device d = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, present_params);

Surface s = Surface.CreateOffscreenPlain(d, 1680, 1050, Format.A8R8G8B8, Pool.Scratch);

d.GetFrontBufferData(0, s);

bmp = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(s, SlimDX.Direct3D9.ImageFileFormat.Bmp));