D3DXCreateTextureFromFileExW
Creates a texture from a file specified by Unicode string. This is a more advanced function than D3DXCreateTextureFromFileW.
HRESULT D3DXCreateTextureFromFileExW(
LPDIRECT3DDEVICE8 pDevice,
LPCWSTR pSrcFile,
UINT Width,
UINT Height,
UINT MipLevels,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
DWORD Filter,
DWORD MipFilter,
D3DCOLOR ColorKey,
D3DXIMAGE_INFO* pSrcInfo,
PALETTEENTRY* pPalette,
LPDIRECT3DTEXTURE8* ppTexture
);
Parameters
- pDevice
- [in] Pointer to an IDirect3DDevice8 interface, representing the device to be associated with the texture.
- pSrcFile
- [in] Pointer to a Unicode string that specifies the file from which to create the texture.
- Width
- [in] Width in pixels. If this value is zero or D3DX_DEFAULT, the dimensions are taken from the file.
- Height
- [in] Height in pixels. If this value is zero or D3DX_DEFAULT, the dimensions are taken from the file.
- MipLevels
- [in] Number of mip levels requested. If this value is zero or D3DX_DEFAULT, a complete mipmap chain is created.
- Usage
- [in] 0 or D3DUSAGE_RENDERTARGET. Setting this flag to D3DUSAGE_RENDERTARGET indicates that the surface is to be used as a render target. The resource can then be passed to the pNewRenderTarget parameter of the SetRenderTarget method. If D3DUSAGE_RENDERTARGET is specified, Pool must be set to D3DPOOL_DEFAULT, and the application should check that the device supports this operation by calling IDirect3D8::CheckDeviceFormat.
- Format
- [in] Member of the D3DFORMAT enumerated type, describing the requested pixel format for the texture. The returned texture might have a different format from that specified by Format. Applications should check the format of the returned texture. If Format is D3DFMT_UNKNOWN, the format is taken from the file.
- Pool
- [in] Member of the D3DPOOL enumerated type, describing the memory class into which the texture should be placed.
- Filter
- [in] A combination of one ore more flags controlling how the image is filtered. Specifying D3DX_DEFAULT for this parameter is the equivalent of specifying D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER.
Each valid filter must contain exactly one of the following flags.
- D3DX_FILTER_BOX
- Each pixel is computed by averaging a 2×2(×2) box of pixels from the source image. This filter works only when the dimensions of the destination are half those of the source, as is the case with mipmaps.
- D3DX_FILTER_LINEAR
- Each destination pixel is computed by sampling the four nearest pixels from the source image. This filter works best when the scale on both axes is less than two.
- D3DX_FILTER_NONE
- No scaling or filtering will take place. Pixels outside the bounds of the source image are assumed to be transparent black.
- D3DX_FILTER_POINT
- Each destination pixel is computed by sampling the nearest pixel from the source image.
- D3DX_FILTER_TRIANGLE
- Every pixel in the source image contributes equally to the destination image. This is the slowest of the filters.
In addition, you can use the OR operator to specify zero or more of the following optional flags with a valid filter.
- D3DX_FILTER_MIRROR
- Specifying this flag is the same as specifying the D3DX_FILTER_MIRROR_U, D3DX_FILTER_MIRROR_V, and D3DX_FILTER_MIRROR_W flags.
- D3DX_FILTER_MIRROR_U
- Pixels off the edge of the texture on the u-axis should be mirrored, not wrapped.
- D3DX_FILTER_MIRROR_V
- Pixels off the edge of the texture on the v-axis should be mirrored, not wrapped.
- D3DX_FILTER_MIRROR_W
- Pixels off the edge of the texture on the w-axis should be mirrored, not wrapped.
- D3DX_FILTER_DITHER
- The resulting image must be dithered using a 4x4 ordered dither algorithm.
- MipFilter
- [in] A combination of one or more flags controlling how the image is filtered. Specifying D3DX_DEFAULT for this parameter is the equivalent of specifying D3DX_FILTER_BOX.
Each valid filter must contain exactly one of the following flags.
- D3DX_FILTER_BOX
- Each pixel is computed by averaging a 2×2(×2) box of pixels from the source image. This filter works only when the dimensions of the destination are half those of the source, as is the case with mipmaps.
- D3DX_FILTER_LINEAR
- Each destination pixel is computed by sampling the four nearest pixels from the source image. This filter works best when the scale on both axes is less than two.
- D3DX_FILTER_NONE
- No scaling or filtering will take place. Pixels outside the bounds of the source image are assumed to be transparent black.
- D3DX_FILTER_POINT
- Each destination pixel is computed by sampling the nearest pixel from the source image.
- D3DX_FILTER_TRIANGLE
- Every pixel in the source image contributes equally to the destination image. This is the slowest of the filters.
In addition, you can use the OR operator to specify zero or more of the following optional flags with a valid filter.
- D3DX_FILTER_MIRROR
- Specifying this flag is the same as specifying the D3DX_FILTER_MIRROR_U, D3DX_FILTER_MIRROR_V, and D3DX_FILTER_MIRROR_W flags.
- D3DX_FILTER_MIRROR_U
- Pixels off the edge of the texture on the u-axis should be mirrored, not wrapped.
- D3DX_FILTER_MIRROR_V
- Pixels off the edge of the texture on the v-axis should be mirrored, not wrapped.
- D3DX_FILTER_MIRROR_W
- Pixels off the edge of the texture on the w-axis should be mirrored, not wrapped.
- D3DX_FILTER_DITHER
- The resulting image must be dithered using a 4x4 ordered dither algorithm.
- ColorKey
- [in] D3DCOLOR value to replace with transparent black, or 0 to disable the colorkey. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque colorkeys. Thus, for opaque black, the value would be equal to 0xFF000000.
- pSrcInfo
- [in, out] Pointer to a D3DXIMAGE_INFO structure to be filled with a description of the data in the source image file, or NULL.
- pPalette
- [out] Pointer to a PALETTEENTRY structure, representing a 256-color palette to fill in, or NULL. See Remarks.
- ppTexture
- [out] Address of a pointer to an IDirect3DTexture8 interface, representing the created texture object.
Return Values
If the function succeeds, the return value is D3D_OK.
If the function fails, the return value can be one of the following values.
Remarks
Mipmapped textures automatically have each level filled with the loaded texture.
When loading images into mipmapped textures, some devices are unable to go to a 1x1 image and this function will fail. If this happens, then the images need to be loaded manually.
For details on PALETTEENTRY, see the Microsoft® Platform Software Development Kit (SDK). Note that as of Microsoft DirectX® 8.0, the peFlags member of the PALLETTEENTRY structure does not function as documented in the Platform SDK. The peFlags member is now the alpha channel for 8-bit palletized formats.
D3DXCreateTextureFromFileEx maps to either D3DXCreateTextureFromFileExA or D3DXCreateTextureFromFileExW, depending on the inclusion or exclusion of the #define UNICODE switch. Include or exclude the #define UNICODE switch to specify whether your application expects Unicode or ANSI strings. The following code fragment shows how D3DXCreateTextureFromFileEx is defined.
#ifdef UNICODE
#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW
#else
#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA
#endif
Header: Declared in D3dx8tex.h.
Import Library: Use D3dx8.lib.
See Also
D3DXCreateTextureFromFileA, D3DXCreateTextureFromFileExA, D3DXCreateTextureFromFileW