FromFile Method (GraphicsDevice, Stream, TextureCreationParameters)

Texture.FromFile Method (GraphicsDevice, Stream, TextureCreationParameters)

Loads a Texture from a file.

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

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


The GraphicsDevice to associate the texture with.
The stream to load the texture from.
Parameters to use when creating the Texture.

Return Value

The created Texture.

Exception typeCondition
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.

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

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

© 2016 Microsoft