Class BitmapContent
Provides properties and methods for creating and maintaining a bitmap resource.
Inheritance
Inherited Members
Namespace: Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly: MonoGame.Framework.Content.Pipeline.dll
Syntax
public abstract class BitmapContent : ContentItem
Constructors
BitmapContent()
Initializes a new instance of BitmapContent.
Declaration
protected BitmapContent()
BitmapContent(Int32, Int32)
Initializes a new instance of BitmapContent with the specified width or height.
Declaration
protected BitmapContent(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | Width, in pixels, of the bitmap resource. |
Int32 | height | Height, in pixels, of the bitmap resource. |
Properties
Height
Gets or sets the height of the bitmap, in pixels.
Declaration
public int Height { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Width
Gets or sets the width of the bitmap, in pixels.
Declaration
public int Width { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
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.
Declaration
public static void Copy(BitmapContent sourceBitmap, BitmapContent destinationBitmap)
Parameters
Type | Name | Description |
---|---|---|
BitmapContent | sourceBitmap | BitmapContent being copied. |
BitmapContent | destinationBitmap | 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.
Declaration
public static void Copy(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
Parameters
Type | Name | Description |
---|---|---|
BitmapContent | sourceBitmap | BitmapContent being copied. |
Rectangle | sourceRegion | Region of sourceBitmap. |
BitmapContent | destinationBitmap | BitmapContent being overwritten. |
Rectangle | destinationRegion | Region of bitmap to be overwritten. |
GetPixelData()
Reads encoded bitmap content.
Declaration
public abstract byte[] GetPixelData()
Returns
Type | Description |
---|---|
Byte[] | Array containing encoded bitmap data. |
SetPixelData(Byte[])
Writes encoded bitmap content.
Declaration
public abstract void SetPixelData(byte[] sourceData)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | sourceData | Array containing encoded bitmap data to be set. |
ToString()
Returns a string description of the bitmap resource.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | Description of the bitmap. |
Overrides
TryCopyFrom(BitmapContent, Rectangle, Rectangle)
Attempts to copy a region from a specified bitmap.
Declaration
protected abstract bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destinationRegion)
Parameters
Type | Name | Description |
---|---|---|
BitmapContent | sourceBitmap | BitmapContent being copied. |
Rectangle | sourceRegion | Location of sourceBitmap. |
Rectangle | destinationRegion | Region of destination bitmap to be overwritten. |
Returns
Type | Description |
---|---|
Boolean | true if region copy is supported; false otherwise. |
TryCopyTo(BitmapContent, Rectangle, Rectangle)
Attempts to copy a region of the specified bitmap onto another.
Declaration
protected abstract bool TryCopyTo(BitmapContent destinationBitmap, Rectangle sourceRegion, Rectangle destinationRegion)
Parameters
Type | Name | Description |
---|---|---|
BitmapContent | destinationBitmap | BitmapContent being overwritten. |
Rectangle | sourceRegion | Location of the source bitmap. |
Rectangle | destinationRegion | Region of destination bitmap to be overwritten. |
Returns
Type | Description |
---|---|
Boolean | true if region copy is supported; false otherwise. |
TryGetFormat(out SurfaceFormat)
Gets the corresponding GPU texture format for the specified bitmap type.
Declaration
public abstract bool TryGetFormat(out SurfaceFormat format)
Parameters
Type | Name | Description |
---|---|---|
SurfaceFormat | format | Format being retrieved. |
Returns
Type | Description |
---|---|
Boolean | The GPU texture format of the bitmap type. |
ValidateCopyArguments(BitmapContent, Rectangle, BitmapContent, Rectangle)
Validates the arguments to the Copy function.
Declaration
protected static void ValidateCopyArguments(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
Parameters
Type | Name | Description |
---|---|---|
BitmapContent | sourceBitmap | BitmapContent being copied. |
Rectangle | sourceRegion | Location of sourceBitmap. |
BitmapContent | destinationBitmap | BitmapContent being overwritten. |
Rectangle | destinationRegion | Region of bitmap to be overwritten. |