WriteableBitmap
Wraps a mutable GDI+ bitmap for RichTextEditor image operations; pixel-buffer members expose raw locked bitmap bytes rather than normalized pixel values.
Definition
Namespace:Telerik.WinControls.RichTextEditor.UI
Assembly:Telerik.WinControls.RichTextEditor.dll
Syntax:
public sealed class WriteableBitmap : BitmapSource
Inheritance: objectBitmapSourceWriteableBitmap
Constructors
Creates a bitmap copy from a WriteableBitmap or from a BitmapImage backed by a MemoryStream with a publicly accessible buffer.
public WriteableBitmap(BitmapSource image)
The supported bitmap source to copy.
Other BitmapSource subtypes are not initialized by this overload.
Creates an independent bitmap copy from a GDI+ image.
Creates a bitmap with the specified dimensions and mapped pixel format.
public WriteableBitmap(int width, int height, int dpiX, int dpiY, PixelFormat pixelFormat)
The bitmap width in pixels.
heightintThe bitmap height in pixels.
dpiXintIgnored; this implementation does not apply a horizontal resolution.
dpiYintIgnored; this implementation does not apply a vertical resolution.
pixelFormatPixelFormatThe pixel format to map to GDI+; unrecognized values use 32-bit ARGB.
Creates an independent bitmap copy of another writable bitmap.
public WriteableBitmap(WriteableBitmap writeableBitmap)
The bitmap to copy.
Properties
Gets the palette entries captured when the backing bitmap was initialized.
public Color[] Colors { get; }
The returned array is cached; changing it does not update the backing bitmap's palette.
Gets the compatibility pixel format mapped from the backing GDI+ format; unmapped formats report Bgra32.
public PixelFormat Format { get; }
Gets the backing bitmap's height in pixels.
public int PixelHeight { get; }
Gets an eagerly created sequence containing one packed integer for each consecutive group of four raw bitmap bytes.
public IEnumerable<int> Pixels { get; }
The sequence is a snapshot made when this property is read; the implementation does not normalize values for pixel format or row padding.
Gets the backing bitmap's width in pixels.
public int PixelWidth { get; }
Methods
Copies raw bitmap bytes row by row into a byte array.
public void CopyPixels(byte[] pixels, int stride, int offset)
The destination byte array.
strideintThe number of bytes copied per row.
offsetintThe starting index in the destination array.
The source row advance uses the backing bitmap's GDI+ stride; bytes are not converted to another pixel format.
Fills the destination with values packed from consecutive groups of four raw bitmap bytes.
public void CopyPixels(int[] pixels, int stride, int offset)
The destination array of packed pixel values.
strideintA legacy row-stride value used only while building an intermediate buffer.
offsetintA legacy byte offset used only while building an intermediate buffer.
The final values are packed directly from consecutive source bytes, so the destination conversion does not apply
strideoroffsetand does not normalize for the bitmap pixel format.
Attempts to write bytes from the supplied packed pixel values into the backing bitmap buffer.
public void WritePixels(Rect rect, int[] pixels, int stride, int offset)
The requested destination rectangle; the current implementation ignores this value.
pixelsint[]The source pixel values, read as raw bytes.
strideintThe number of bytes per destination row used to calculate bitmap-buffer coordinates.
offsetintThe starting index in the source buffer.
This implementation writes from the bitmap origin and does not convert pixel formats. It requests a read-only GDI+ lock before copying data back to the bitmap.