Class WriteableBitmap
Holds a writeable bitmap image.
public class WriteableBitmap : Bitmap, IImage, IDisposable, IImageBrushSource
- Inheritance
-
WriteableBitmap
- Implements
- Inherited Members
Constructors
WriteableBitmap(PixelSize, Vector, PixelFormat?, AlphaFormat?)
Initializes a new instance of the WriteableBitmap class.
public WriteableBitmap(PixelSize size, Vector dpi, PixelFormat? format = null, AlphaFormat? alphaFormat = null)
Parameters
size
PixelSizeThe size of the bitmap in device pixels.
dpi
VectorThe DPI of the bitmap.
format
PixelFormat?The pixel format (optional).
alphaFormat
AlphaFormat?The alpha format (optional).
WriteableBitmap(PixelFormat, AlphaFormat, nint, PixelSize, Vector, int)
Initializes a new instance of the WriteableBitmap class with existing pixel data The data is copied to the bitmap
public WriteableBitmap(PixelFormat format, AlphaFormat alphaFormat, nint data, PixelSize size, Vector dpi, int stride)
Parameters
format
PixelFormatThe pixel format.
alphaFormat
AlphaFormatThe alpha format.
data
nintThe pointer to the source bytes.
size
PixelSizeThe size of the bitmap in device pixels.
dpi
VectorThe DPI of the bitmap.
stride
intThe number of bytes per row.
Properties
Format
public override PixelFormat? Format { get; }
Property Value
Methods
CopyPixels(PixelRect, nint, int, int)
public override void CopyPixels(PixelRect sourceRect, nint buffer, int bufferSize, int stride)
Parameters
Decode(Stream)
public static WriteableBitmap Decode(Stream stream)
Parameters
stream
Stream
Returns
DecodeToHeight(Stream, int, BitmapInterpolationMode)
Loads a Bitmap from a stream and decodes at the desired height. Aspect ratio is maintained. This is more efficient than loading and then resizing.
public static WriteableBitmap DecodeToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)
Parameters
stream
StreamThe stream to read the bitmap from. This can be any supported image format.
height
intThe desired height of the resulting bitmap.
interpolationMode
BitmapInterpolationModeThe BitmapInterpolationMode to use should any scaling be required.
Returns
- WriteableBitmap
An instance of the WriteableBitmap class.
DecodeToWidth(Stream, int, BitmapInterpolationMode)
Loads a WriteableBitmap from a stream and decodes at the desired width. Aspect ratio is maintained. This is more efficient than loading and then resizing.
public static WriteableBitmap DecodeToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)
Parameters
stream
StreamThe stream to read the bitmap from. This can be any supported image format.
width
intThe desired width of the resulting bitmap.
interpolationMode
BitmapInterpolationModeThe BitmapInterpolationMode to use should any scaling be required.
Returns
- WriteableBitmap
An instance of the WriteableBitmap class.
Lock()
public ILockedFramebuffer Lock()