Show / Hide Table of Contents

Class WriteableBitmap

Provides a BitmapSource that can be written to and updated.

Inheritance
System.Object
DependencyObject
ImageSource
BitmapSource
WriteableBitmap
Inherited Members
BitmapSource.SetSource(Stream)
BitmapSource.PixelHeightProperty
BitmapSource.PixelHeight
BitmapSource.PixelWidthProperty
BitmapSource.PixelWidth
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.INTERNAL_OnAttachedToVisualTree()
DependencyObject.INTERNAL_OnDetachedFromVisualTree()
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Media.Imaging
Assembly: OpenSilver.dll
Syntax
public sealed class WriteableBitmap : BitmapSource, IDependencyObject

Constructors

| Improve this Doc View Source

WriteableBitmap(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

pixelWidth or pixelHeight is zero or less.

| Improve this Doc View Source

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

source is null.

| Improve this Doc View Source

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

element is null.

Properties

| Improve this Doc View Source

Pixels

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.

| Improve this Doc View Source

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 Source

CreateAsync(BitmapSource)

Declaration
public static async Task<WriteableBitmap> CreateAsync(BitmapSource source)
Parameters
Type Name Description
BitmapSource source
Returns
Type Description
System.Threading.Tasks.Task<WriteableBitmap>
| Improve this Doc View Source

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>
| Improve this Doc View Source

Invalidate()

Requests a draw or redraw of the entire bitmap.

Declaration
public void Invalidate()
| Improve this Doc View Source

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

element is null.

| Improve this Doc View Source

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
| Improve this Doc View Source

WaitToInitialize()

User must call WaitToInitialize after instantiation in order to load the buffer

Declaration
public Task WaitToInitialize()
Returns
Type Description
System.Threading.Tasks.Task

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
  • Improve this Doc
  • View Source