ReadableBitmapDataExtensionsToWriteableBitmap(IReadableBitmapData, PixelFormat, IQuantizer, IDitherer) Method

Converts the specified source to a WriteableBitmap that has the specified PixelFormat.

Definition

Namespace: KGySoft.Drawing.Wpf
Assembly: KGySoft.Drawing.Wpf (in KGySoft.Drawing.Wpf.dll) Version: 8.1.0
C#
public static WriteableBitmap ToWriteableBitmap(
	this IReadableBitmapData source,
	PixelFormat pixelFormat,
	IQuantizer? quantizer = null,
	IDitherer? ditherer = null
)

Parameters

source  IReadableBitmapData
The source IReadableBitmapData instance to convert.
pixelFormat  PixelFormat
The desired result pixel format.
quantizer  IQuantizer  (Optional)
An optional IQuantizer instance to determine the colors of the result. If and pixelFormat is an indexed format, then a default palette and quantization logic will be used. This parameter is optional.
Default value: .
ditherer  IDitherer  (Optional)
The ditherer to be used. Might be ignored if quantizer is not specified and pixelFormat represents an at least 24 bits-per-pixel size. This parameter is optional.
Default value: .

Return Value

WriteableBitmap
A WriteableBitmap converted from the specified source.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IReadableBitmapData. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

  Note

This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation or reporting progress. Use the BeginToWriteableBitmap or ToWriteableBitmapAsync (in .NET Framework 4.0 and above) methods for asynchronous call and to adjust parallelization, set up cancellation and for reporting progress.

To produce a WriteableBitmap with the best matching pixel format to source, use the ToWriteableBitmap(IReadableBitmapData) overload instead.

Exceptions

ArgumentNullExceptionsource is .
ArgumentOutOfRangeExceptionpixelFormat does not specify a valid format.
ArgumentExceptionThe quantizer palette contains too many colors for the indexed format specified by pixelFormat.

See Also