Texture2D.FromStream Method (GraphicsDevice, Stream, Int32, Int32, Boolean)
Loads texture data from a stream.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)
Syntax
public static Texture2D FromStream (
GraphicsDevice graphicsDevice,
Stream stream,
int width,
int height,
bool zoom
)
Parameters
- graphicsDevice
A graphics device. - stream
Data stream from one of the following file types: .gif, .jpg or .png. - width
The requested image width. - height
The requested image height. - zoom
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.
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.
See Also
Reference
Texture2D Class
Texture2D Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone 7