Texture2D Class (Microsoft.Xna.Framework.Graphics)


Namespace: Microsoft.Xna.Framework.Graphics
Assembly: MonoGame.Framework (MonoGame.Framework.dll 3.8.0.1082)
  • C#
  • VB
  • F#
public class Texture2D : Texture

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

The Texture2D type exposes the following members.

  Platforms Name Description
Texture2D(GraphicsDevice, int, int) Creates a new texture of the given size 
Texture2D(GraphicsDevice, int, int, bool, SurfaceFormat) Creates a new texture of a given size with a surface format and optional mipmaps 
Texture2D(GraphicsDevice, int, int, bool, SurfaceFormat, int) Creates a new texture array of a given size with a surface format and optional mipmaps. Throws ArgumentException if the current GraphicsDevice can't work with texture arrays 
Texture2D(GraphicsDevice, int, int, bool, SurfaceFormat, SurfaceType, bool, int)  
Top
  Platforms Name Description
Bounds Gets the dimensions of the texture 
Format  (Inherited from Texture.)
GraphicsDevice  (Inherited from GraphicsResource.)
Height Gets the height of the texture in pixels. 
IsDisposed  (Inherited from GraphicsResource.)
LevelCount  (Inherited from Texture.)
Mipmap  
Name  (Inherited from GraphicsResource.)
SampleDescription  
Shared  
Tag  (Inherited from GraphicsResource.)
Width Gets the width of the texture in pixels. 
Top
  Platforms Name Description
CreateSampleDescription  
CreateShaderResourceView  (Inherited from Texture.)
Dispose()  (Inherited from GraphicsResource.)
Dispose(bool) The method that derived classes should override to implement disposing of managed and native resources. (Overrides Texture.Dispose().)
Finalize  (Inherited from GraphicsResource.)
FromFile Creates a Texture2D from a file, supported formats bmp, gif, jpg, png, tif and dds (only for simple textures). May work with other formats, but will not work with tga files. This internally calls FromStream(GraphicsDevice, Stream)
FromStream Creates a Texture2D from a stream, supported formats bmp, gif, jpg, png, tif and dds (only for simple textures). May work with other formats, but will not work with tga files. 
GetData<T>(int, int, Nullable<Rectangle>, T[], int, int) Retrieves the contents of the texture Throws ArgumentException if data is null, data.length is too short or if arraySlice is greater than 0 and the GraphicsDevice doesn't support texture arrays 
GetData<T>(int, Nullable<Rectangle>, T[], int, int) Retrieves the contents of the texture Throws ArgumentException if data is null, data.length is too short or if arraySlice is greater than 0 and the GraphicsDevice doesn't support texture arrays 
GetData<T>(T[], int, int) Retrieves the contents of the texture Throws ArgumentException if data is null, data.length is too short or if arraySlice is greater than 0 and the GraphicsDevice doesn't support texture arrays 
GetData<T>(T[]) Retrieves the contents of the texture Throws ArgumentException if data is null, data.length is too short or if arraySlice is greater than 0 and the GraphicsDevice doesn't support texture arrays 
GetSharedHandle Gets the handle to a shared resource. (Inherited from Texture.)
GetTexture2DDescription  
GraphicsDeviceResetting Called before the device is reset. Allows graphics resources to invalidate their state so they can be recreated after the device reset. Warning: This may be called after a call to Dispose() up until the resource is garbage collected. (Inherited from Texture.)
Reload  
SaveAsJpeg Converts the texture to a JPG image 
SaveAsPng Converts the texture to a PNG image 
SetData<T>(T[]) Changes the texture's pixels 
SetData<T>(T[], int, int) Changes the texture's pixels 
SetData<T>(int, Nullable<Rectangle>, T[], int, int) Changes the pixels of the texture 
SetData<T>(int, int, Nullable<Rectangle>, T[], int, int) Changes the pixels of the texture Throws ArgumentNullException if data is null Throws ArgumentException if arraySlice is greater than 0, and the GraphicsDevice does not support texture arrays 
ToString  (Inherited from GraphicsResource.)
Top
  Platforms Name Description
Disposing  (Inherited from GraphicsResource.)
Top
Supported in:

    
 Windows DirectX Desktop
    
 Linux Desktop
    
 Windows OpenGL Desktop
    
 Web