PeachDrawing.Win2D

Win2dComposer Class

An offscreen drawing: a bitmap the size of a page and the Win2dCanvas that draws on it, to be read back as pixels or saved as an image file.

public sealed class Win2dComposer : System.IDisposable

Inheritance System.Object → Win2dComposer

Implements System.IDisposable

Remarks

Lifetime. The composer owns the bitmap, the drawing session on it and the canvas over that session. Finish() (called by SaveAsync(Stream, Win2dImageFormat) and ToPixelBuffer() when needed) disposes the canvas, which closes the session; after that the drawing is complete and no more can be added. Dispose() finishes and then releases the bitmap. The render context is not owned: dispose it separately, after the composer.

Reading or saving a drawing whose device was lost throws Win2dDeviceLostException.

Constructors  
Win2dComposer(Win2dRenderContext, double, double, Win2dComposerOptions) Makes a drawing widthPoints by heightPoints points, cleared to the background.
Properties  
Canvas The canvas that draws on the bitmap. It is disposed by Finish().
HeightPoints The height of the page, in points.
Links The links and named places painted so far; usable after the composer is disposed.
PixelHeight The height of the bitmap, in pixels.
PixelWidth The width of the bitmap, in pixels.
RenderContext The render context the canvas draws with.
WidthPoints The width of the page, in points.
Methods  
Dispose() Finishes the drawing if it is not already, then releases the bitmap. Safe to call more than once.
Finish() Completes the drawing: pops anything still pushed on the canvas and closes its session, so the bitmap can be read. Safe to call more than once; nothing can be drawn afterwards.
SaveAsync(Stream, Win2dImageFormat) Writes the finished bitmap to destination as an image file. The stream is left open.
ToPixelBuffer() The finished bitmap as premultiplied RGBA pixels, the form the rest of PeachDrawing exchanges images in.