D3DXCreateTextureFromFileInMemory() 使用总结

D3DXCreateTextureFromFileInMemory

从内存数据中创建一张d3d纹理

HRESULT D3DXCreateTextureFromFileInMemory(
  LPDIRECT3DDEVICE9 pDevice,
  LPCVOID pSrcData,
  UINT SrcDataSize,
  LPDIRECT3DTEXTURE9 * ppTexture
);

Parameters 参数

pDevice
[in]  IDirect3DDevice9 d3d9设备指针。
pSrcData
[in] 指向内存数据的首地址.
SrcDataSize
[in] 要拷贝的大小(byte).
ppTexture
[out] IDirect3DTexture9类型的输出纹理指针.

 细节注意:

该函数只支持 .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga. 这几种格式的内存数据,一定要保持正确的格式,否则该函数不知道如何创建 从而失败;

HBITMAP或则BITMAP都必须转化成正确的.bmp格式,方能正常创建;

 

D3DXCreateTextureFromFileEx()使用总结

D3DXCreateTextureFromFileEx()能够更加精确地创建纹理,特别是指定纹理的KeyColor从而创建一张具有镂空半透明的纹理,

HRESULT D3DXCreateTextureFromFileInMemoryEx(
  LPDIRECT3DDEVICE9 pDevice,                                          // d3d设备指针
  LPCVOID pSrcData,                                                              // 图形源内存地址
  UINT SrcDataSize,                                                                // 图形大小
  UINT Width,                                                                            //  纹理大小
  UINT Height,                                                                           // 纹理高
  UINT MipLevels,                                                                     // mipMap级数
  DWORD Usage,                                                                     // 可以是0,D3DUSAGE_RENDERTARGET,和                                                                                                      D3DUSAGE_DYNAMIC
  D3DFORMAT Format,                                                          
  D3DPOOL Pool,                                                                      // 内存池( D3DPOOL_MANAGED)
  DWORD Filter,                                                                         // 过滤器( 一般D3DX_DEFAULT)
  DWORD MipFilter,                                                                  // mip过滤器(一般D3DX_DEFUALT)
  D3DCOLOR ColorKey,                                                          // 关键色
  D3DXIMAGE_INFO * pSrcInfo,                                             // 图像信息,可传入 传出
  PALETTEENTRY * pPalette,                                                 // 调色板信息
  LPDIRECT3DTEXTURE9 * ppTexture
);

你可能感兴趣的:(D3DXCreateTextureFromFileInMemory() 使用总结)