Share via


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

Note

This method is available only when developing for Windows.

Creates a texture resource from a stream, specifying the number of bytes in the stream and the texture creation parameters to use.

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

Syntax

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

Parameters

  • graphicsDevice
    The graphics device to use to create the texture resource.
  • textureStream
    Stream containing the volume texture data.
  • numberBytes
    The number of bytes in textureStream.
  • creationParameters
    The parameters to use when creating this texture.

Return Value

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

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

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

Platforms

Windows XP SP2, Windows Vista