简体   繁体   中英

Save surface to file without DirectX(d3dx9_43.dll)

I making a program that takes screenshots, I use GetFrontBufferData and D3DXSaveSurfaceToFile . But now I am facing trouble. D3DXSaveSurfaceToFile uses d3dx9_43.dll, that cannot be static linked, and program didn't work on pc without directx. How I can save surface, using only D3D?

GetFrontBufferData gets you a pointer to the IDirect3DSurface9 . Calling IDirect3DSurface9::GetDesc will give you D3DSURFACE_DESC , describing the image data. Most important for saving it to a file are Format , Width and Height members. Then, you can call IDirect3DSurface9::LockRect to obtain the actual data. The output of this function is a D3DLOCKED_RECT , which contains the image data in the pBits member. Note that the image data might not be tightly packed, you will have to take into account the Pitch member of the D3DLOCKED_RECT . You can then use any static linkable image library, (eg. DevIL) to write the image out to disk, or roll-your-own image writer (writing a BMP/TGA is quite easy).

Or, you could just install the proper DirectX runtime on the target computer, which would probably be a lot easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM