【发布时间】:2015-01-24 22:43:17
【问题描述】:
使用 SlimDX 并尝试从纹理中获取内存流。我收到错误:E_FAIL:发生未确定的错误 (-2147467259)。这应该很简单吧?
这是我的设备声明:
`d3dDevice11 = new SlimDX.Direct3D11.Device(DriverType.Hardware, DeviceCreationFlags.Debug);
还有我的纹理声明:
Texture2DDescription textureDesc = new Texture2DDescription();
textureDesc.BindFlags = BindFlags.ShaderResource |
BindFlags.RenderTarget;
textureDesc.Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm;
textureDesc.Width = _inputWidth;
textureDesc.Height = _inputHeight;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0);
textureDesc.Usage = ResourceUsage.Default;
textureDesc.OptionFlags = ResourceOptionFlags.Shared;
textureDesc.CpuAccessFlags = CpuAccessFlags.None;
textureDesc.ArraySize = 1;
_texture = new Texture2D(d3dDevice11, textureDesc);
以及获取 Stream 的调用:
MemoryStream newMemStream = new MemoryStream();
SlimDX.Result sdxRes = SlimDX.Direct3D11.Texture2D.ToFile(
_texture.Device.ImmediateContext,
_texture,
SlimDX.Direct3D11.ImageFileFormat.Bmp,
(Stream)newMemStream);
谁能告诉我我做错了什么?
谢谢, 道格
【问题讨论】:
标签: c# wpf directx-11 slimdx