Share via


Texture2D.FromStream Method (GraphicsDevice, Stream, Int32, Int32, Boolean)

Loads texture data from a stream.

Syntax

'Declaration
Public Shared Function FromStream ( _
         graphicsDevice As GraphicsDevice, _
         stream As Stream, _
         width As Integer, _
         height As Integer, _
         zoom As Boolean _
) As Texture2D 
public static Texture2D FromStream (
         GraphicsDevice graphicsDevice,
         Stream stream,
         int width,
         int height,
         bool zoom
)
public:
static Texture2D FromStream(
         GraphicsDevice graphicsDevice,
         Stream stream,
         int width,
         int height,
         bool zoom
)

Parameters

  • graphicsDevice
    Type: GraphicsDevice
    A graphics device.
  • stream
    Type: Stream
    Data stream from one of the following file types: .gif, .jpg or .png.
  • width
    Type: Int32
    The requested image width.
  • height
    Type: Int32
    The requested image height.
  • zoom
    Type: Boolean
    Control the aspect ratio when zooming (scaling); set to false to maintain a constant aspect ratio, true otherwise. See remarks.

Return Value

Type: Texture2D
A 2D texture whose format is SurfaceFormat.Color and contains non-premultiplied alpha data.

Remarks

When zooming, the image is scaled relative to the image center.

  • Set zoom to false to maintain the aspect ratio which may result in the width or height returned not matching the values requested.
  • Set zoom to true to scale the image to fit the requested height and width regardless of the aspect ratio. This may result in clipping some of the original image.

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Reference

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

Platforms

Windows Phone