次の方法で共有


Texture.FromFile Method (GraphicsDevice, Stream, Int32, TextureCreationParameters)

Note

This method is available only when developing for Windows.

Loads a Texture from a file.

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

Syntax

public static Texture FromFile (
         GraphicsDevice graphicsDevice,
         Stream textureStream,
         int numberBytes,
         TextureCreationParameters creationParameters
)

Parameters

  • graphicsDevice
    The GraphicsDevice to associate the texture with.
  • textureStream
    The stream to load the texture from.
  • numberBytes
    The number of bytes in the stream.
  • creationParameters
    Parameters to use when creating the Texture.

Return Value

The created Texture.

Exceptions

Exception type Condition
ArgumentNullException textureStream is null. The stream passed into this method cannot be null.
NotSupportedException textureStream is not readable. Streams passed into this method must be readable.
EndOfStreamException textureStream does not contain enough data to support this call.

Remarks

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

See Also

Reference

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

Platforms

Windows XP SP2, Windows Vista