Table of Contents

Class TextureExtensions.TextureData

Namespace
MLEM.Textures
Assembly
MLEM.dll

A struct that represents the data of a texture, accessed through GetTextureData(Texture2D).

public class TextureExtensions.TextureData : IDisposable
Inheritance
TextureExtensions.TextureData
Implements
Inherited Members

Constructors

TextureData(Texture2D)

Creates a new texture data instance for the given texture. Note that this can more easily be invoked using GetTextureData(Texture2D).

public TextureData(Texture2D texture)

Parameters

texture Texture2D

The texture whose data to get

Properties

this[Point]

Returns the color at the given x,y position of the texture, where 0,0 represents the bottom left.

public Color this[Point point] { get; set; }

Parameters

point Point

Property Value

Color

this[int, int]

Returns the color at the given x,y position of the texture, where 0,0 represents the bottom left.

public Color this[int x, int y] { get; set; }

Parameters

x int

The x coordinate of the texture location

y int

The y coordinate of the texture location

Property Value

Color

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FromIndex(int)

Converts the given index from the Microsoft.Xna.Framework.Graphics.Texture2D.GetData<T>(T[]) array into the corresponding x,y texture coordinate.

public Point FromIndex(int index)

Parameters

index int

The texture array index

Returns

Point

The corresponding texture coordinate

Exceptions

ArgumentException

If the given index is out of bounds

IsInBounds(int, int)

Checks if the given x,y texture coordinates is within the bounds of the underlying texture.

public bool IsInBounds(int x, int y)

Parameters

x int

The x coordinate

y int

The y coordinate

Returns

bool

Whether the given coordinate is within bounds of the underlying texture

Store()

Stores this texture data back into the underlying texture

public void Store()

ToIndex(int, int)

Converts the given x,y texture coordinate to the corresponding index in the Microsoft.Xna.Framework.Graphics.Texture2D.GetData<T>(T[]) array.

public int ToIndex(int x, int y)

Parameters

x int

The x coordinate

y int

The y coordinate

Returns

int

The corresponding texture array index

Exceptions

ArgumentException

If the given coordinate is out of bounds