?/TD>
Microsoft DirectX 9.0

D3DXLoadSurfaceFromFile Function


Loads a surface from a file.

Syntax

HRESULT D3DXLoadSurfaceFromFile(      

    LPDIRECT3DSURFACE9 pDestSurface,     CONST PALETTEENTRY* pDestPalette,     CONST RECT* pDestRect,     LPCTSTR pSrcFile,     CONST RECT* pSrcRect,     DWORD Filter,     D3DCOLOR ColorKey,     D3DXIMAGE_INFO* pSrcInfo );

Parameters

pDestSurface
[in] Pointer to an IDirect3DSurface9 interface. Specifies the destination surface, which receives the image.
pDestPalette
[in] Pointer to a PALETTEENTRY structure, the destination palette of 256 colors or NULL.
pDestRect
[in] Pointer to a RECT structure. Specifies the destination rectangle. Set this parameter to NULL to specify the entire surface.
pSrcFile
[in] Pointer to a string that specifies the filename. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR. See Remarks.
pSrcRect
[in] Pointer to a RECT structure. Specifies the source rectangle. Set this parameter to NULL to specify the entire image.
Filter
[in] Combination of one or more D3DX_FILTER controlling how the image is filtered. Specifying D3DX_DEFAULT for this parameter is the equivalent of specifying D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER.
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 color keys 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.

Return Value

If the function succeeds, the return value is D3D_OK.

If the function fails, the return value can be one of the following values.

D3DERR_INVALIDCALLThe method call is invalid. For example, a method's parameter may have an invalid value.
D3DXERR_INVALIDDATAThe data is invalid.


Remarks

The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXLoadSurfaceFromFileW. Otherwise, the function call resolves to D3DXLoadSurfaceFromFileA because ANSI strings are being used.

This function supports the following file formats: .bmp, .dds, .dib, .jpg, .png, and .tga.

This function handles conversion to and from compressed texture formats.

Writing to a non-level-zero surface will not cause the dirty rectangle to be updated. If D3DXLoadSurfaceFromFile is called and the surface was not already dirty (this is unlikely under normal usage scenarios), the application needs to explicitly call IDirect3DTexture9::AddDirtyRect on the surface.

Function Information

Headerd3dx9tex.h
Import libraryd3dx9.lib
Minimum operating systems Windows 98

See Also

Texture Color Conversions


© 2002 Microsoft Corporation. All rights reserved.