Skip to main content

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.

Definition

Namespace: Avalonia.Media.Imaging
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public static WriteableBitmap DecodeToWidth(
Stream stream,
int width,
BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality
)

Parameters

  Stream
The stream to read the bitmap from. This can be any supported image format.
  Int32
The desired width of the resulting bitmap.
  BitmapInterpolationMode  (Optional)
The BitmapInterpolationMode to use should any scaling be required.

Return Value

WriteableBitmap
An instance of the WriteableBitmap class.

See Also

Reference

WriteableBitmap Class
Avalonia.Media.Imaging Namespace