WriteableBitmap
Stores a mutable GDI+ bitmap behind the Spreadsheet WPF-compatible bitmap-source API.
Definition
Namespace:Telerik.WinControls.Spreadsheet.UI
Assembly:Telerik.WinControls.RadSpreadsheet.dll
Syntax:
public sealed class WriteableBitmap : BitmapSource
Inheritance: objectBitmapSourceWriteableBitmap
Constructors
Creates a bitmap from a supported Spreadsheet bitmap-source type.
public WriteableBitmap(BitmapSource image)
A WriteableBitmap or BitmapImage to copy.
Other BitmapSource implementations are not initialized by this constructor.
Creates a bitmap by copying the pixels from a GDI+ image.
Creates a bitmap with the specified dimensions and pixel format.
public WriteableBitmap(int width, int height, int dpiX, int dpiY, PixelFormat pixelFormat)
The bitmap width in pixels.
heightintThe bitmap height in pixels.
dpiXintUnused; this implementation does not apply horizontal DPI.
dpiYintUnused; this implementation does not apply vertical DPI.
pixelFormatPixelFormatThe compatibility pixel format to map to a GDI+ pixel format.
Pixel formats without an explicit mapping fall back to 32bpp ARGB.
Creates an independent bitmap copy of the specified writable bitmap.
public WriteableBitmap(WriteableBitmap writeableBitmap)
The writable bitmap to copy.
Properties
Gets the backing GDI+ bitmap.
public Bitmap Bitmap { get; }
The returned bitmap is the mutable instance used for rendering; changes made through it are visible to this source.
Gets the palette colors captured when the backing bitmap was created.
public Color[] Colors { get; }
This is a cached array; modifying it does not update the backing bitmap's palette.
Gets the backing GDI+ pixel format mapped to the compatibility format enumeration.
public PixelFormat Format { get; }
Formats without an explicit mapping are reported as Bgra32.
Gets the backing bitmap height in pixels.
public int PixelHeight { get; }
Gets the backing bitmap bytes grouped into consecutive four-byte integer values.
public IEnumerable<int> Pixels { get; }
This sequence is built from the raw buffer without pixel-format or row-stride conversion. A buffer whose length is not divisible by four cannot be read completely by this implementation.
Gets the backing bitmap width in pixels.
public int PixelWidth { get; }
Methods
Copies raw bitmap-buffer bytes into a destination byte array.
public void CopyPixels(byte[] pixels, int stride, int offset)
The destination byte array.
strideintThe number of destination bytes processed per row.
offsetintThe starting destination byte index.
Bytes are copied without pixel-format conversion; source rows are advanced using the backing bitmap's GDI+ stride.
Copies groups of four bytes from the bitmap buffer into integer values.
public void CopyPixels(int[] pixels, int stride, int offset)
The destination integer array.
strideintThe requested row stride; it does not affect the integer values copied by this implementation.
offsetintThe requested destination offset; it is not applied to the integer values by this implementation.
The current implementation packs consecutive source bytes and does not convert according to the bitmap pixel format.
Copies integer data into the backing bitmap buffer.
public void WritePixels(Rect rect, int[] pixels, int stride, int offset)
The requested destination rectangle; the current implementation does not use it.
pixelsint[]The source integer values, copied as raw bytes.
strideintThe byte stride used to calculate source rows.
offsetintThe starting byte offset in the source data.
The implementation writes through a bitmap lock opened with ReadOnly; callers should not rely on the write being supported by the GDI+ implementation.