当前位置:网站首页>D3D10 截图功能 保存Texture到本地
D3D10 截图功能 保存Texture到本地
2022-06-22 05:34:00 【王建博09】
Date 20200311 By Wjb
直接上代码:
ID3D10Resource* pScreen;
mRenderTargetView->GetResource(&pScreen);
D3D10_TEXTURE2D_DESC texDesc;
texDesc.ArraySize = 1;
texDesc.CPUAccessFlags = 0;
texDesc.Width = (unsigned int)mClientWidth;
texDesc.Height = (unsigned int)mClientHeight;;
texDesc.SampleDesc.Count = 8;
texDesc.SampleDesc.Quality = 0;
texDesc.ArraySize = 1;
texDesc.MipLevels = 1;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS;
texDesc.SampleDesc.Count = 1;
texDesc.SampleDesc.Quality = 0;
texDesc.Usage = D3D10_USAGE_DEFAULT;
texDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
ID3D10Texture2D *texture;
HRESULT hr = md3dDevice->CreateTexture2D(&texDesc, 0, &texture);
md3dDevice->CopyResource(texture, pScreen);
char filename [245];
sprintf(filename, "TestFile%d.dds", name);
hr = D3DX10SaveTextureToFileA(texture, D3DX10_IFF_DDS, filename);
texture->Release();
pScreen->Release();我保存事DDS格式文件,在VS中打开效果如下图所以

我附了功能源码,环境VS2013 d3d10。下载地址:
边栏推荐
猜你喜欢

MinGW下载安装

Xshell download and installation (solve the problem of expired evaluation)

Working method: 3C scheme design method

vscode 远程连接错误:Server status check failed - waiting and retrying

Machine learning note 8: octave for handwritten digit recognition based on Neural Network

Machine learning Note 6: number recognition of multiple classification problems in logistic regression

數據的存儲(進階)

Record some problems and solutions encountered in processing SIF data

C指针的理解

Machine learning note 7: powerful neural network representation
随机推荐
想投放Facebook广告却不知从何入手?此文带你深入了解
信号输出库
數據的存儲(進階)
Optimization direction of code walk through (convenient interface requests, long dynamic class judgment conditions, removal of useless consoles, separation of public methods)
我不建议你工作太拼命
Go语言使用zap日志库
Go language uses JWT
RGB及sRGB与XYZ坐标转换
Development forecast and investment risk outlook report of China's GaAs industry during the 14th Five Year Plan period 2022-2027
innosetup判断程序已经运行方法
Why is "CPS alliance marketing" the most cost-effective promotion method?
JTAG接口
tmux -- ssh terminal can be closed without impact the server process
向量空间视角看高数(1)——系列简介
Error: note: module requires go 1.17
Market survey and future production and marketing demand analysis report of China's zinc oxide nanoparticle industry 2022-2027
Assertion based validation
Analysis of annual average temperature based on TMP data in cru
触 发 器
Current market situation analysis and investment analysis prospect report of global and Chinese ceramic capacitor industry 2022-2027