Compartir a través de


TextureLoader.FromFile Method (Device, String, Int32, Int32, Int32, Usage, Format, Pool, Filter, Filter, Int32)

Creates a texture from a file.

Namespace: Microsoft.WindowsMobile.DirectX.Direct3D
Assembly: Microsoft.WindowsMobile.DirectX (in microsoft.windowsmobile.directx.dll)

Syntax

'Declaration
Public Shared Function FromFile ( _
    device As Device, _
    srcFile As String, _
    width As Integer, _
    height As Integer, _
    mipLevels As Integer, _
    usage As Usage, _
    format As Format, _
    pool As Pool, _
    filter As Filter, _
    mipFilter As Filter, _
    colorKey As Integer _
) As Texture
'Usage
Dim device As Device
Dim srcFile As String
Dim width As Integer
Dim height As Integer
Dim mipLevels As Integer
Dim usage As Usage
Dim format As Format
Dim pool As Pool
Dim filter As Filter
Dim mipFilter As Filter
Dim colorKey As Integer
Dim returnValue As Texture

returnValue = TextureLoader.FromFile(device, srcFile, width, height, mipLevels, usage, format, pool, filter, mipFilter, colorKey)
public static Texture FromFile (
    Device device,
    string srcFile,
    int width,
    int height,
    int mipLevels,
    Usage usage,
    Format format,
    Pool pool,
    Filter filter,
    Filter mipFilter,
    int colorKey
)
public:
static Texture^ FromFile (
    Device^ device, 
    String^ srcFile, 
    int width, 
    int height, 
    int mipLevels, 
    Usage usage, 
    Format format, 
    Pool pool, 
    Filter filter, 
    Filter mipFilter, 
    int colorKey
)
public static Texture FromFile (
    Device device, 
    String srcFile, 
    int width, 
    int height, 
    int mipLevels, 
    Usage usage, 
    Format format, 
    Pool pool, 
    Filter filter, 
    Filter mipFilter, 
    int colorKey
)
public static function FromFile (
    device : Device, 
    srcFile : String, 
    width : int, 
    height : int, 
    mipLevels : int, 
    usage : Usage, 
    format : Format, 
    pool : Pool, 
    filter : Filter, 
    mipFilter : Filter, 
    colorKey : int
) : Texture
Not applicable.

Parameters

  • device
    A Device that represents the device to associate with the texture.
  • srcFile
    String that specifies the file name.
  • width
    Width of the texture in pixels. If this value is zero, the dimensions are taken from the file.
  • height
    Height of the texture in pixels. If this value is zero, the dimensions are taken from the file.
  • mipLevels
    Number of mip levels requested. If this value is 0, a complete mipmap chain is created.
  • usage
    Specify zero or Usage values. Specify RenderTarget to indicate that the surface will be used as a render target. The resource can then be passed to the renderTarget parameter for the SetRenderTarget method of a Device. The application should determine whether the device supports this operation by using the CheckDeviceFormat method of a Manager.

    Specify Dynamic to indicate that the surface should be handled dynamically.

  • format
    Format value that describes the requested pixel format for the cube texture.
  • pool
    Pool value that describes the memory class into which the cube texture should be placed.
  • filter
    One or more Filter flags that control how the image is filtered.
  • mipFilter
    One or more Filter flags that control how the mipmaps are filtered.
  • colorKey
    A value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color that is independent of the source image format. Alpha is significant, and usually should be set to FF for opaque color keys. For example, for opaque black, the value is equal to 0xFF000000.

Return Value

A Texture that represents the created texture object.

Remarks

This method supports the following file formats: .bmp, .dds, .jpg, .png, and .gif.

To get the best performance with this method, consider the following:

  • Doing image scaling and format conversion at load time can be slow. Store images in the format and resolution in which they will be used. If the target hardware requires power of 2 dimensions, use it to create and store images.

  • For mipmap image creation at load time, filter using Box. A box filter is much faster than other filter types such as Triangle.

  • Consider using DDS files. Since they can be used to represent any Microsoft DirectX texture format, they are easily read by this method. Also, they can store mipmaps, which means that any mipmap generation algorithms can be used to author the images.

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Compact Framework

Supported in: 2.0

See Also

Reference

TextureLoader Class
TextureLoader Members
Microsoft.WindowsMobile.DirectX.Direct3D Namespace