Class WriteableBitmap
Provides a BitmapSource that can be written to and updated.
Inherited Members
Namespace: System.Windows.Media.Imaging
Assembly: OpenSilver.dll
Syntax
public sealed class WriteableBitmap : BitmapSource, IDependencyObject
Constructors
| Improve this Doc View SourceWriteableBitmap(Int32, Int32)
Initializes a new instance of the WriteableBitmap class using the provided dimensions.
Declaration
public WriteableBitmap(int pixelWidth, int pixelHeight)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pixelWidth | The width of the bitmap. |
System.Int32 | pixelHeight | The height of the bitmap. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
WriteableBitmap(BitmapSource)
Initializes a new instance of the WriteableBitmap class using the provided BitmapSource.
Declaration
public WriteableBitmap(BitmapSource source)
Parameters
Type | Name | Description |
---|---|---|
BitmapSource | source | The BitmapSource to use for initialization. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
WriteableBitmap(UIElement, Transform)
Initializes a new instance of the WriteableBitmap class using the provided element and transform.
Declaration
public WriteableBitmap(UIElement element, Transform transform)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The desired element to be rendered within the bitmap. |
Transform | transform | The transform the user wants to apply to the element as the last step before drawing into the bitmap. This is particularly interesting for you if you want the bitmap to respect its transform. This value can be null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Properties
| Improve this Doc View SourcePixels
Gets an array representing the 2-D texture of the bitmap.
Declaration
public int[] Pixels { get; }
Property Value
Type | Description |
---|---|
System.Int32[] | An array of integers representing the 2-D texture of the bitmap. |
UseSilverlightCompatibilityMode
Gets or sets a value indicating if WriteableBitmap should follow Silverlight's behavior to set its Pixels. In Silverlight, a pixel is stored in an System.Int32 in the format BGRA, while OpenSilver stores it in the RGBA format. In other words, this means the first and third bytes are swapped.
Declaration
public static bool UseSilverlightCompatibilityMode { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A flag that indicates if the Silverlight compatibility mode is enabled. The default value is false. |
Methods
| Improve this Doc View SourceCreateAsync(BitmapSource)
Declaration
public static async Task<WriteableBitmap> CreateAsync(BitmapSource source)
Parameters
Type | Name | Description |
---|---|---|
BitmapSource | source |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<WriteableBitmap> |
CreateAsync(UIElement, Transform)
Declaration
public static async Task<WriteableBitmap> CreateAsync(UIElement element, Transform transform)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | |
Transform | transform |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<WriteableBitmap> |
Invalidate()
Requests a draw or redraw of the entire bitmap.
Declaration
public void Invalidate()
Render(UIElement, Transform)
Renders an element within the bitmap.
Declaration
public void Render(UIElement element, Transform transform)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The element to be rendered within the bitmap. |
Transform | transform | The transform to apply to the element before drawing into the bitmap. If an empty transform is supplied, the bits representing the element show up at the same offset as if they were placed within their parent. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
RenderAsync(UIElement, Transform)
Declaration
public Task RenderAsync(UIElement element, Transform transform)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | |
Transform | transform |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
WaitToInitialize()
User must call WaitToInitialize after instantiation in order to load the buffer
Declaration
public Task WaitToInitialize()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |