Microsoft DirectX 8.1 (Visual Basic)

D3DX8.CreateTextureFromFile

Creates a texture from a file.

object.CreateTextureFromFile( _ 
    Device As Direct3DDevice8, _ 
    SrcFile As String) As Direct3DTexture8

Parts

object
Object expression that resolves to a D3DX8 object.
Device
Direct3DDevice8 object representing the device to be associated with the texture.
SrcFile
String that specifies the file from which to create the texture.

Return Values

Direct3DTexture8 object representing the created texture.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DERR_NOTAVAILABLE
D3DERR_OUTOFVIDEOMEMORY
D3DXERR_INVALIDDATA
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

Mipmapped textures will automatically have each level filled with the loaded texture.

When loading images into mipmapped textures, some video cards are unable to go to a 1x1 image and this function will fail. If this happens, then the images need to be loaded manually.

Note that a resource created with this function will be placed in the memory class denoted by the D3DPOOL_MANAGED member of the CONST_D3DPOOL enumerated type.