New to Telerik UI for WinForms? Start a free 30-day trial

Holds a mutable bitmap copy and exposes its pixel data through the diagram's bitmap compatibility API.

Definition

Namespace:Telerik.WinControls.UI.Diagrams

Assembly:Telerik.WinControls.RadDiagram.dll

Syntax:

C#
public sealed class WriteableBitmap : BitmapSource

Inheritance: objectBitmapSourceWriteableBitmap

Constructors

Creates a copy from a supported diagram bitmap source.

C#
public WriteableBitmap(BitmapSource image)
Parameters:imageBitmapSource

A WriteableBitmap or a BitmapImage with an assigned stream.

Other BitmapSource implementations are not handled and leave Bitmap null.

Creates an independent bitmap copy of the specified image.

C#
public WriteableBitmap(Image bitmapSource)
Parameters:bitmapSourceImage

The image to copy.

Creates a blank bitmap with the specified dimensions and pixel format.

C#
public WriteableBitmap(int width, int height, int dpiX, int dpiY, PixelFormat pixelFormat)
Parameters:widthint

The bitmap width in pixels.

heightint

The bitmap height in pixels.

dpiXint

Accepted for API compatibility; it does not set the bitmap resolution.

dpiYint

Accepted for API compatibility; it does not set the bitmap resolution.

pixelFormatPixelFormat

The pixel format to use. Unsupported formats fall back to 32-bit ARGB.

Creates an independent copy of another writable bitmap.

C#
public WriteableBitmap(WriteableBitmap writeableBitmap)
Parameters:writeableBitmapWriteableBitmap

The bitmap to copy.

Properties

Gets the backing bitmap. Changes made to this object affect this WriteableBitmap.

C#
public Bitmap Bitmap { get; }

Gets the color entries copied from the bitmap's palette during initialization.

C#
public Color[] Colors { get; }

Gets the compatibility pixel format corresponding to the backing bitmap's format; unrecognized formats are reported as Bgra32.

C#
public PixelFormat Format { get; }

Gets the backing bitmap height in pixels.

C#
public int PixelHeight { get; }

Pixels

IEnumerable<int>

Gets the backing bitmap bytes grouped into four-byte integer values.

C#
public IEnumerable<int> Pixels { get; }

Gets the backing bitmap width in pixels.

C#
public int PixelWidth { get; }

Methods

Copies the backing bitmap bytes into a byte array, using the supplied stride and destination offset.

C#
public void CopyPixels(byte[] pixels, int stride, int offset)
Parameters:pixelsbyte[]

The destination byte array.

strideint

The number of bytes to copy per row.

offsetint

The starting index in pixels.

Copies the backing bitmap data into four-byte integer values.

C#
public void CopyPixels(int[] pixels, int stride, int offset)
Parameters:pixelsint[]

The destination array for packed pixel values.

strideint

The stride used while creating an intermediate byte copy; it does not determine the final integer grouping.

offsetint

The offset used for the intermediate byte copy. An out-of-range offset can cause an indexing exception.

The intermediate copy is discarded. The destination values are grouped from the start of the bitmap buffer, so valid stride and offset values do not change the final grouping.

Copies integer pixel data into the backing bitmap buffer.

C#
public void WritePixels(Rect rect, int[] pixels, int stride, int offset)
Parameters:rectRect

Ignored by this implementation; the write starts at the beginning of the bitmap buffer.

pixelsint[]

The source pixel values.

strideint

The number of bytes per row in the copied data.

offsetint

The starting byte offset in the source data.

The current implementation does not use rect to limit the affected pixels.