PeachDrawing.Skia

SkiaComposer Class

A drawing of one page onto a surface the caller supplies: it scales the page to fill the surface, clears it, and gives the SkiaCanvas to draw with, then reads the result back as pixels or saves it as an image file.

public sealed class SkiaComposer : System.IDisposable

Inheritance System.Object → SkiaComposer

Implements System.IDisposable

Remarks

Lifetime. The composer allocates no surface. It borrows the SkiaSharp.SKSurface it is given (CPU or GPU) and never disposes it or the context. Finish() (called by Save(Stream, SkiaImageFormat, int) and ToPixelBuffer() when needed) disposes the canvas, which puts the surface’s canvas back as it found it; after that the drawing is complete and no more can be added. Dispose() finishes it.

Constructors  
SkiaComposer(SkiaRenderContext, SKSurface, double, double, SkiaComposerOptions) Makes a drawing widthPoints by heightPoints points that fills surface.
Properties  
Canvas The canvas that draws on the surface. 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 surface, in pixels.
PixelWidth The width of the surface, 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. The surface is the caller’s and stays open. Safe to call more than once.
Finish() Completes the drawing: pops anything still pushed on the canvas and puts the surface’s canvas back as it was, so the surface can be read. Safe to call more than once; nothing can be drawn afterwards.
Save(Stream, SkiaImageFormat, int) Writes the finished drawing to destination as an image file. The stream is left open.
ToPixelBuffer() The finished drawing as premultiplied RGBA pixels, the form the rest of PeachDrawing exchanges images in.