Table of Contents

Class BitmapContent

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 abstract class BitmapContent : ContentItem
Inheritance
BitmapContent
Derived
Inherited Members

Constructors

BitmapContent()

Initializes a new instance of BitmapContent.

protected BitmapContent()

BitmapContent(int, int)

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

protected BitmapContent(int width, int height)

Parameters

width int

Width, in pixels, of the bitmap resource.

height int

Height, in pixels, of the bitmap resource.

Properties

Height

Gets or sets the height of the bitmap, in pixels.

public int Height { get; protected set; }

Property Value

int

Width

Gets or sets the width of the bitmap, in pixels.

public int Width { get; protected set; }

Property Value

int

Methods

Copy(BitmapContent, BitmapContent)

Copies one bitmap into another. The destination bitmap can be in any format and size. If the destination is larger or smaller, the source bitmap is scaled accordingly.

public static void Copy(BitmapContent sourceBitmap, BitmapContent destinationBitmap)

Parameters

sourceBitmap BitmapContent

BitmapContent being copied.

destinationBitmap BitmapContent

BitmapContent being overwritten.

Copy(BitmapContent, Rectangle, BitmapContent, Rectangle)

Copies one bitmap into another. The destination bitmap can be in any format and size. If the destination is larger or smaller, the source bitmap is scaled accordingly.

public static void Copy(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)

Parameters

sourceBitmap BitmapContent

BitmapContent being copied.

sourceRegion Rectangle

Region of sourceBitmap.

destinationBitmap BitmapContent

BitmapContent being overwritten.

destinationRegion Rectangle

Region of bitmap to be overwritten.

GetPixelData()

Reads encoded bitmap content.

public abstract byte[] GetPixelData()

Returns

byte[]

Array containing encoded bitmap data.

SetPixelData(byte[])

Writes encoded bitmap content.

public abstract void SetPixelData(byte[] sourceData)

Parameters

sourceData byte[]

Array containing encoded bitmap data to be set.

ToString()

Returns a string description of the bitmap resource.

public override string ToString()

Returns

string

Description of the bitmap.

TryCopyFrom(BitmapContent, Rectangle, Rectangle)

Attempts to copy a region from a specified bitmap.

protected abstract 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 abstract 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 abstract bool TryGetFormat(out SurfaceFormat format)

Parameters

format SurfaceFormat

Format being retrieved.

Returns

bool

The GPU texture format of the bitmap type.

ValidateCopyArguments(BitmapContent, Rectangle, BitmapContent, Rectangle)

Validates the arguments to the Copy function.

protected static void ValidateCopyArguments(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)

Parameters

sourceBitmap BitmapContent

BitmapContent being copied.

sourceRegion Rectangle

Location of sourceBitmap.

destinationBitmap BitmapContent

BitmapContent being overwritten.

destinationRegion Rectangle

Region of bitmap to be overwritten.