DirectX SDK |
The D3DXLoadTextureFromMemory function loads a mipmap level from memory, performing the necessary color conversion.
HRESULT D3DXLoadTextureFromMemory( LPDIRECT3DDEVICE7 pd3dDevice, LPDIRECTDRAWSURFACE7 pTexture, DWORD mipMapLevel, LPVOID pMemory, LPDIRECTDRAWPALETTE pDDPal, D3DX_SURFACEFORMAT srcPixelFormat, DWORD srcPitch, RECT* pDestRect, D3DX_FILTERTYPE filterType );
If the function succeeds, the return value is S_OK.
If the function fails, the return value may be one of the following values:
D3DXERR_D3DXNOTSTARTEDYET |
D3DXERR_INVALIDPARAMETER |
D3DXERR_NOMEMORY |
D3DXERR_NULLPOINTER |
DDERR_INVALIDOBJECT |
DDERR_INVALIDPARAMS |
DDERR_NOTFOUND |
DDERR_SURFACELOST |
DDERR_UNSUPPORTED |
This function provides a mechanism to copy some pixels from memory to a surface.
If the destination surface was created by Direct3DX, then the RECT structure should be specified in the original coordinates of that surface.
Concerning the mipMapLevel parameter:
This function assumes that the source (memory) has been loaded in full.
This function supports a full range of color-conversion for all surface formats that can be described by a D3DX_SURFACEFORMAT structure. It also implements filtered re-scaling and updates mipmaps automatically.
By taking pDestRect in the space of the original image, the application does not have to worry about how the surface may have been resized as part of the D3DXCreateTexture routine. For example, if an image was 100x150 pixels, then it may end up being 128x256 or 256x256 on different configurations. In both cases, the RECT structure to use to update the upper left quadrant is (0, 0, 50, 75); as if no resizing had taken place.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Windows CE: Unsupported.
Version: Requires DirectX 7.0.
Header: Declared in d3dxcore.h.
Library: Use d3dx.lib.