Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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

XNA Game Studio 4.0
Loads texture data from a stream.

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

public static Texture2D FromStream (
         GraphicsDevice graphicsDevice,
         Stream stream,
         int width,
         int height,
         bool zoom


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

Return Value

A 2D texture.

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.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone 7

Community Additions

© 2015 Microsoft