D3D9
创建一个空纹理,当返回 S_OK
且 ppTexture
纹理对象指针不为 NULL
时,则表示该函数调用成功。
HRESULT D3DXCreateTexture(
_In_ LPDIRECT3DDEVICE9 pDevice,
_In_ UINT Width,
_In_ UINT Height,
_In_ UINT MipLevels,
_In_ DWORD Usage,
_In_ D3DFORMAT Format,
_In_ D3DPOOL Pool,
_Out_ LPDIRECT3DTEXTURE9 *ppTexture
);
HRESULT D3DXCreateTextureFromFileInMemory(
_In_ LPDIRECT3DDEVICE9 pDevice,
_In_ LPCVOID pSrcData,
_In_ UINT SrcDataSize,
_Out_ LPDIRECT3DTEXTURE9 *ppTexture
);
HRESULT D3DXCreateTextureFromFileInMemoryEx(
_In_ LPDIRECT3DDEVICE9 pDevice,
_In_ LPCVOID pSrcData,
_In_ UINT SrcDataSize,
_In_ UINT Width,
_In_ UINT Height,
_In_ UINT MipLevels,
_In_ DWORD Usage,
_In_ D3DFORMAT Format,
_In_ D3DPOOL Pool,
_In_ DWORD Filter,
_In_ DWORD MipFilter,
_In_ D3DCOLOR ColorKey,
_Inout_ D3DXIMAGE_INFO *pSrcInfo,
_Out_ PALETTEENTRY *pPalette,
_Out_ LPDIRECT3DTEXTURE9 *ppTexture
);
在 D3DXCreateTextureFromFileInMemory
和 D3DXCreateTextureFromFileInMemoryEx
函数下断(注意看纹理对象指针 ppTexture
是否和上面创建的纹理对象是否一致),一般就可以把内存中的图像保存下来了。上面三个函数参数具体含义,请自行查看 https://docs.microsoft.com/zh-cn/windows/desktop/api/_direct3d9/ 官网。
OpenGL
void glGetTexImage(
GLenum target,
GLint level,
GLenum format,
GLenum type,
GLvoid * pixels
);
void glGetnTexImage(
GLenum target,
GLint level,
GLenum format,
GLenum type,
GLsizei bufSize,
void *pixels
);
void glGetTextureImage(
GLuint texture,
GLint level,
GLenum format,
GLenum type,
GLsizei bufSize,
void *pixels
);
具体参数请自行参考OPENGL API:https://www.khronos.org/registry/OpenGL-Refpages/gl4/