Platform SDK: DirectX |
The D3DXCreateTextureFromFile function creates a texture object from a stand-alone file or from the resource.
HRESULT D3DXCreateTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice, LPDWORD pFlags, LPDWORD pWidth, LPDWORD pHeight, D3DX_SURFACEFORMAT* pPixelFormat, LPDIRECTDRAWPALETTE pDDPal, LPDIRECTDRAWSURFACE7* ppDDSurf, LPDWORD pNumMipMaps, LPSTR pSrcName, D3DX_FILTERTYPE filterType );
If the function succeeds, the return value is S_OK.
If the function fails, the return value may be NULL or one of the following values:
Only BMP and DIB files are supported from the resource portion of the executable.
In the pSrcName parameter, TGA is supported for the following cases: 16-, 24-, and 32-bpp direct color and 8-bpp palettized. Also, 8- and 16-bpp gray scale is supported. RLE versions of the preceding TGA formats are also supported. Note that colorkeying and premultiplied alpha are not currently supported for TGA files.
Specifying a numeric ID for the pSrcName parameter instructs the D3DXLoadTextureFromFile function to load bitmap images from the executable's resource; otherwise, pSrcName is assumed to be a file name. Note that you cannot use the string resource name, since the D3DXCreateTextureFromFile function treats a string pointer as a file name.
Unless the pFlags parameter is set to specifically prevent creating mipmaps, mipmaps are generated until reaching the minimum level size of 1x1.
For more information on mipmaps, see Texture Filtering With Mipmaps.
Width, height and pixel format are altered based on available hardware. For example, mipmap dimensions may be required to be powers of 2 and width may be required to be equal to height for square textures. Also, if the specified pixel format is unavailable, a best fit will be made.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Version: Requires DirectX 7.0.
Header: Declared in d3dxcore.h.
Library: Use d3dx.lib.