Skip to main content

Bitmap Class

Definition

Assembly:Avalonia.Base
Package:Avalonia
Source:Bitmap.cs

Holds a bitmap image.

public class Bitmap

Inheritance: object -> Bitmap

Implements: IImage, IImageBrushSource, IBitmap, IDisposable

Constructors

NameDescription
Bitmap (3 overloads)Initializes a new instance of the Avalonia.Media.Imaging.Bitmap class.

Bitmap overloads

Bitmap Constructor

Initializes a new instance of the Avalonia.Media.Imaging.Bitmap class.

public Bitmap(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.

Bitmap Constructor

Initializes a new instance of the Avalonia.Media.Imaging.Bitmap class.

public Bitmap(System.IO.Stream stream)
Parameters

stream System.IO.Stream

The stream to read the bitmap from.

Bitmap Constructor

Initializes a new instance of the Avalonia.Media.Imaging.Bitmap class.

public Bitmap(string fileName)
Parameters

fileName string

The filename of the bitmap.

Methods

NameDescription
CopyPixels (2 overloads)No summary available.
CreateScaledBitmapCreates a Bitmap scaled to a specified size from the current bitmap.
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 Bitmap from a stream and decodes at the desired width. Aspect ratio is maintained. This is more efficient than loading and then resizing.
DisposeNo summary available.
Save (2 overloads)No summary available.

CopyPixels overloads

CopyPixels Method

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

sourceRect Avalonia.PixelRect

buffer IntPtr

bufferSize int

stride int

CopyPixels Method

Copies pixels to the target buffer and transcodes the pixel and alpha format if needed.

public void CopyPixels(Avalonia.Platform.ILockedFramebuffer buffer)
Parameters

buffer Avalonia.Platform.ILockedFramebuffer

The target buffer.

Exceptions

CreateScaledBitmap Method

Creates a Bitmap scaled to a specified size from the current bitmap.

public Avalonia.Media.Imaging.Bitmap CreateScaledBitmap(Avalonia.PixelSize destinationSize, Avalonia.Media.Imaging.BitmapInterpolationMode interpolationMode)

Parameters

destinationSize Avalonia.PixelSize

The destination size.

interpolationMode Avalonia.Media.Imaging.BitmapInterpolationMode

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

Returns

Avalonia.Media.Imaging.Bitmap

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

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.Bitmap 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.Bitmap

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

DecodeToWidth Method

Loads a Bitmap 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.Bitmap 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.Bitmap

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

Dispose Method

public void Dispose()

Save overloads

Save Method

public void Save(System.IO.Stream stream, Nullable<int> quality)
Parameters

stream System.IO.Stream

quality Nullable<int>

Save Method

public void Save(string fileName, Nullable<int> quality)
Parameters

fileName string

quality Nullable<int>

Properties

NameDescription
AlphaFormatNo summary available.
DpiNo summary available.
FormatNo summary available.
PixelSizeNo summary available.
SizeGets the size of the image, in device independent pixels.

AlphaFormat Property

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

Dpi Property

public Avalonia.Vector Dpi { get; set; }

Format Property

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

PixelSize Property

public Avalonia.PixelSize PixelSize { get; set; }

Size Property

Gets the size of the image, in device independent pixels.

public Avalonia.Size Size { get; set; }