Skip to main content

WriteableBitmap Class

Definition

Assembly:Avalonia.Base
Package:Avalonia

Holds a writeable bitmap image.

public class WriteableBitmap

Inheritance: object -> Bitmap -> WriteableBitmap

Constructors

NameDescription
WriteableBitmap (2 overloads)No summary available.

WriteableBitmap overloads

WriteableBitmap Constructor

public WriteableBitmap(Avalonia.PixelSize size, Avalonia.Vector dpi, Nullable<Avalonia.Platform.PixelFormat> format, Nullable<Avalonia.Platform.AlphaFormat> alphaFormat)
Parameters

size Avalonia.PixelSize

dpi Avalonia.Vector

format Nullable<Avalonia.Platform.PixelFormat>

alphaFormat Nullable<Avalonia.Platform.AlphaFormat>

WriteableBitmap Constructor

Initializes a new instance of the Avalonia.Media.Imaging.WriteableBitmap class with existing pixel data The data is copied to the bitmap

public WriteableBitmap(Avalonia.Platform.PixelFormat format, Avalonia.Platform.AlphaFormat alphaFormat, IntPtr data, Avalonia.PixelSize size, Avalonia.Vector dpi, int stride)
Parameters

format Avalonia.Platform.PixelFormat

The pixel format.

alphaFormat Avalonia.Platform.AlphaFormat

The alpha format.

data IntPtr

The pointer to the source bytes.

size Avalonia.PixelSize

The size of the bitmap in device pixels.

dpi Avalonia.Vector

The DPI of the bitmap.

stride int

The number of bytes per row.

Methods

NameDescription
CopyPixelsNo summary available.
DecodeNo summary available.
DecodeToHeightLoads a Bitmap from a stream and decodes at the desired height. Aspect ratio is maintained. This is more efficient than loading and then resizing.
DecodeToWidthLoads a WriteableBitmap from a stream and decodes at the desired width. Aspect ratio is maintained. This is more efficient than loading and then resizing.
LockNo summary available.
CopyPixelsCopies pixels to the target buffer and transcodes the pixel and alpha format if needed. Inherited from Bitmap.
CreateScaledBitmapCreates a Bitmap scaled to a specified size from the current bitmap. Inherited from Bitmap.
DisposeInherited from Bitmap.
Save (2 overloads)Inherited from Bitmap.

CopyPixels Method

public void CopyPixels(Avalonia.PixelRect sourceRect, IntPtr buffer, int bufferSize, int stride)

Parameters

sourceRect Avalonia.PixelRect

buffer IntPtr

bufferSize int

stride int

Decode Method

public Avalonia.Media.Imaging.WriteableBitmap Decode(System.IO.Stream stream)

Parameters

stream System.IO.Stream

Returns

Avalonia.Media.Imaging.WriteableBitmap

DecodeToHeight Method

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 Avalonia.Media.Imaging.WriteableBitmap DecodeToHeight(System.IO.Stream stream, int height, Avalonia.Media.Imaging.BitmapInterpolationMode interpolationMode)

Parameters

stream System.IO.Stream

The stream to read the bitmap from. This can be any supported image format.

height int

The desired height of the resulting bitmap.

interpolationMode Avalonia.Media.Imaging.BitmapInterpolationMode

The Avalonia.Media.Imaging.BitmapInterpolationMode to use should any scaling be required.

Returns

Avalonia.Media.Imaging.WriteableBitmap

An instance of the Avalonia.Media.Imaging.WriteableBitmap class.

DecodeToWidth Method

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 Avalonia.Media.Imaging.WriteableBitmap DecodeToWidth(System.IO.Stream stream, int width, Avalonia.Media.Imaging.BitmapInterpolationMode interpolationMode)

Parameters

stream System.IO.Stream

The stream to read the bitmap from. This can be any supported image format.

width int

The desired width of the resulting bitmap.

interpolationMode Avalonia.Media.Imaging.BitmapInterpolationMode

The Avalonia.Media.Imaging.BitmapInterpolationMode to use should any scaling be required.

Returns

Avalonia.Media.Imaging.WriteableBitmap

An instance of the Avalonia.Media.Imaging.WriteableBitmap class.

Lock Method

public Avalonia.Platform.ILockedFramebuffer Lock()

Returns

Avalonia.Platform.ILockedFramebuffer

Properties

NameDescription
FormatNo summary available.
AlphaFormatInherited from Bitmap.
DpiInherited from Bitmap.
PixelSizeInherited from Bitmap.
SizeGets the size of the image, in device independent pixels. Inherited from Bitmap.

Format Property

public Nullable<Avalonia.Platform.PixelFormat> Format { get; set; }