Table of Contents

Method WriteSource

Namespace
PaintDotNet.Imaging
Assembly
PaintDotNet.Windows.dll

WriteSource(IBitmapSource, in RectInt32?)

Encodes a bitmap source.

void WriteSource(IBitmapSource bitmapSource, in RectInt32? sourceRect = null)

Parameters

bitmapSource IBitmapSource
sourceRect RectInt32?

Remarks

If SetSize(SizeInt32) is not called prior to calling WriteSource, the size given in sourceRect is used if not null. Otherwise, the size of the IBitmapSource given in bitmapSource is used.

If SetPixelFormat(in PixelFormat, out PixelFormat) is not called prior to calling WriteSource, the pixel format of the IBitmapSource given in sourceRect is used.

If SetResolution(Vector2Double) is not called prior to calling WriteSource, the pixel format of the IBitmapSource given in sourceRect is used.

When encoding a GIF image, if the global palette is set and the frame level palette is not set directly by the user or by a custom independent software vendor (ISV) GIF codec, WriteSource will use the global palette to encode the frame even when bitmapSource has a frame level palette.

Repeated WriteSource calls can be made as long as the total accumulated source rect height is the same as set through SetSize(SizeInt32).

The source rect must be at least the dimensions set through SetSize(SizeInt32). If the source rect width exceeds the SetSize(SizeInt32) width, extra pixels on the right side are ignored. If the source rect height exceeds the remaining unfilled height, extra scan lines on the bottom are ignored.

See also: https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmapframeencode-writesource