共用方式為


Texture3D.FromFile Method (GraphicsDevice, String, Int32, Int32, Int32)

Note

This method is available only when developing for Windows.

Creates a volume texture resource from a file, specifying the width, height, and depth in pixels.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public static Texture3D FromFile (
         GraphicsDevice graphicsDevice,
         string filename,
         int width,
         int height,
         int depth
)

Parameters

  • graphicsDevice
    The graphics device to use to create the texture resource.
  • filename
    The name of the file containing the texture.
  • width
    The width, in pixels, of the texture.
  • height
    The height, in pixels, of the texture.
  • depth
    The depth, in pixels, of the texture.

Return Value

The texture resource that has been created on the specified graphics device.

Exceptions

Exception type Condition
ArgumentException filename is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
ArgumentNullException filename is null.
PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
DirectoryNotFoundException The specified path is invalid (for example, it is on an unmapped drive).
UnauthorizedAccessException The filename parameter specifies a directory, or the caller does not have the required permission to access the file specified by filename.
FileNotFoundException The file specified in filename was not found.
NotSupportedException filename is in an invalid format.

Remarks

The supported texture image file formats are described by the ImageFileFormat enumeration.

See Also

Reference

Texture3D Class
Texture3D Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Windows XP SP2, Windows Vista