WriteableBitmap Constructors

Definition

Initializes a new instance of the WriteableBitmap class.

Overloads

WriteableBitmap(BitmapSource)

Initializes a new instance of the WriteableBitmap class using the given BitmapSource.

WriteableBitmap(Int32, Int32, Double, Double, PixelFormat, BitmapPalette)

Initializes a new instance of the WriteableBitmap class with the specified parameters.

WriteableBitmap(BitmapSource)

Initializes a new instance of the WriteableBitmap class using the given BitmapSource.

C#
[System.Security.SecurityCritical]
public WriteableBitmap(System.Windows.Media.Imaging.BitmapSource source);
C#
public WriteableBitmap(System.Windows.Media.Imaging.BitmapSource source);

Parameters

source
BitmapSource

The BitmapSource to use for initialization.

Attributes

Remarks

The WriteableBitmap(Int32, Int32, Double, Double, PixelFormat, BitmapPalette) constructor is preferred over using this constructor.

If source does not use a natively supported bitmap format, format conversions are applied for each frame update, which reduces performance.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

WriteableBitmap(Int32, Int32, Double, Double, PixelFormat, BitmapPalette)

Initializes a new instance of the WriteableBitmap class with the specified parameters.

C#
[System.Security.SecurityCritical]
public WriteableBitmap(int pixelWidth, int pixelHeight, double dpiX, double dpiY, System.Windows.Media.PixelFormat pixelFormat, System.Windows.Media.Imaging.BitmapPalette palette);
C#
public WriteableBitmap(int pixelWidth, int pixelHeight, double dpiX, double dpiY, System.Windows.Media.PixelFormat pixelFormat, System.Windows.Media.Imaging.BitmapPalette palette);

Parameters

pixelWidth
Int32

The desired width of the bitmap.

pixelHeight
Int32

The desired height of the bitmap.

dpiX
Double

The horizontal dots per inch (dpi) of the bitmap.

dpiY
Double

The vertical dots per inch (dpi) of the bitmap.

pixelFormat
PixelFormat

The PixelFormat of the bitmap.

palette
BitmapPalette

The BitmapPalette of the bitmap.

Attributes

Remarks

The preferred values for pixelFormat are Bgr32 and Pbgra32. These formats are natively supported and do not require a format conversion. Other pixelFormat values require a format conversion for each frame update, which reduces performance.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10