Table of Contents

Class PixelBitmapContent<T>

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly
MonoGame.Framework.Content.Pipeline.dll

Provides properties and methods for creating and maintaining a bitmap resource.

public class PixelBitmapContent<T> : BitmapContent where T : struct, IEquatable<T>

Type Parameters

T
Provides properties and methods for creating and maintaining a bitmap resource.
Inheritance
PixelBitmapContent<T>
Inherited Members

Constructors

PixelBitmapContent(int, int)

Initializes a new instance of PixelBitmapContent with the specified width or height.

public PixelBitmapContent(int width, int height)

Parameters

width int

Width, in pixels, of the bitmap resource.

height int

Height, in pixels, of the bitmap resource.

Methods

GetPixel(int, int)

Gets the pixel at the specified location.

public T GetPixel(int x, int y)

Parameters

x int

Pixel x coordinate.

y int

Pixel y coordinate.

Returns

T

The pixel for the specified location.

GetPixelData()

Reads encoded bitmap content.

public override byte[] GetPixelData()

Returns

byte[]

Array containing encoded bitmap data.

GetRow(int)

Returns pixel data for the given row.

public T[] GetRow(int y)

Parameters

y int

The row index.

Returns

T[]

Array containing the pixel data for the given row.

Exceptions

ArgumentOutOfRangeException

Row is outside the bounds of the bitmap.

ReplaceColor(T, T)

Replaces all pixels of the specified color with the new color.

public void ReplaceColor(T originalColor, T newColor)

Parameters

originalColor T

The color to replace.

newColor T

The color to replace it with.

SetPixel(int, int, T)

Sets the pixel at the specified location.

public void SetPixel(int x, int y, T value)

Parameters

x int

Pixel x coordinate.

y int

Pixel y coordinate.

value T

The new pixel value.

SetPixelData(byte[])

Writes encoded bitmap content.

public override void SetPixelData(byte[] sourceData)

Parameters

sourceData byte[]

Array containing encoded bitmap data to be set.

TryCopyFrom(BitmapContent, Rectangle, Rectangle)

Attempts to copy a region from a specified bitmap.

protected override bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destinationRegion)

Parameters

sourceBitmap BitmapContent

BitmapContent being copied.

sourceRegion Rectangle

Location of sourceBitmap.

destinationRegion Rectangle

Region of destination bitmap to be overwritten.

Returns

bool

true if region copy is supported; false otherwise.

TryCopyTo(BitmapContent, Rectangle, Rectangle)

Attempts to copy a region of the specified bitmap onto another.

protected override bool TryCopyTo(BitmapContent destinationBitmap, Rectangle sourceRegion, Rectangle destinationRegion)

Parameters

destinationBitmap BitmapContent

BitmapContent being overwritten.

sourceRegion Rectangle

Location of the source bitmap.

destinationRegion Rectangle

Region of destination bitmap to be overwritten.

Returns

bool

true if region copy is supported; false otherwise.

TryGetFormat(out SurfaceFormat)

Gets the corresponding GPU texture format for the specified bitmap type.

public override bool TryGetFormat(out SurfaceFormat format)

Parameters

format SurfaceFormat

Format being retrieved.

Returns

bool

The GPU texture format of the bitmap type.