微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

检索要通过networking发送的ID3D11Texture2D数据

我正在修改Microsoft提供的桌面重复API示例,以捕获屏幕并通过networking将更新发送到我的应用程序。 我知道如何实际发送数据; 我的问题是从ID3D11Texture2D对象获取数据。

ID3D11Texture2D* m_AcquiredDesktopImage; IdxgiResource* desktopResource = nullptr; dxgi_OUTDUPL_FRAME_INFO FrameInfo; // Get new frame HRESULT hr = m_DeskDupl->AcquireNextFrame(500,&FrameInfo,&desktopResource); // QI for IdxgiResource hr = desktopResource->QueryInterface(__uuidof(ID3D11Texture2D),reinterpret_cast<void **>(&m_AcquiredDesktopImage));

在这一点上,我认为屏幕更新是在m_AcquiredDesktopImage 。 我需要通过电线传输这些数据(尽可能高效)。

这个答案似乎是正确的,但我是Windows编程的新手,所以我需要一些额外的帮助。

这是我可以想象利用IdxgiObject::GetPrivateData唯一的解决scheme

使用PTRACE(2)读取进程的stderr

一个平台(MacOSX),而不是另一个(Linux)

框架设置e.Cancel为true吗?

由malloc()分配的数据不是零

Ubunturecursion地列出文件,检测sym-links

AF_UNIX的整数值是多less?

使用mmioOpen发现奇怪文件未find错误

自动播放处理程序:错误的剪贴板格式?

未定义的引用'cpu_ZERO'

无法redirect程序的控制台输出

私人数据不是你正在寻找的。 他们只是在这里自定义值附加到d3d对象。

一旦获得了ID3D11Texture2D对象,您需要从ID3D11Device创建第二个映像池(获取原始描述,更改池并删除绑定)。

然后,您需要使用ID3D11DeviceContext使用ID3D11DeviceContext将纹理复制到您的临时copyResource 。 然后,您可以使用上下文Map和Unmap api来读取图像。

我有一个很好的链接,这样做..寻找方法SaveTexturetoBmp

[...] // map the texture ComPtr<ID3D11Texture2D> mappedTexture; D3D11_MAPPED_SUBRESOURCE mapInfo; mapInfo.RowPitch; hr = d3dContext->Map( Texture,// Subresource D3D11_MAP_READ,// MapFlags &mapInfo); if (Failed(hr)) { // If we Failed to map the texture,copy it to a staging resource if (hr == E_INVALIDARG) { D3D11_TEXTURE2D_DESC desc2; desc2.Width = desc.Width; desc2.Height = desc.Height; desc2.MipLevels = desc.MipLevels; desc2.ArraySize = desc.ArraySize; desc2.Format = desc.Format; desc2.SampleDesc = desc.SampleDesc; desc2.Usage = D3D11_USAGE_STAGING; desc2.BindFlags = 0; desc2.cpuAccessFlags = D3D11_cpu_ACCESS_READ; desc2.MiscFlags = 0; ComPtr<ID3D11Texture2D> stagingTexture; hr = d3dDevice->CreateTexture2D(&desc2,nullptr,&stagingTexture); if (Failed(hr)) { throw MyException::Make(hr,L"Failed to create staging texture"); } // copy the texture to a staging resource d3dContext->copyResource(stagingTexture.Get(),Texture); // Now,map the staging resource hr = d3dContext->Map( stagingTexture.Get(),D3D11_MAP_READ,&mapInfo); if (Failed(hr)) { throw MyException::Make(hr,L"Failed to map staging texture"); } mappedTexture = std::move(stagingTexture); } else { throw MyException::Make(hr,L"Failed to map texture."); } } else { mappedTexture = Texture; } auto unmapResource = Finally([&] { d3dContext->Unmap(mappedTexture.Get(),0); }); [...] hr = frameEncode->WritePixels( desc.Height,mapInfo.RowPitch,desc.Height * mapInfo.RowPitch,reinterpret_cast<BYTE*>(mapInfo.pData)); if (Failed(hr)) { throw MyException::Make(hr,L"frameEncode->WritePixels(...) Failed."); }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐