PeachDrawing.Skia 0.10.0

dotnet add package PeachDrawing.Skia --version 0.10.0
                    
NuGet\Install-Package PeachDrawing.Skia -Version 0.10.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PeachDrawing.Skia" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PeachDrawing.Skia" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="PeachDrawing.Skia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PeachDrawing.Skia --version 0.10.0
                    
#r "nuget: PeachDrawing.Skia, 0.10.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PeachDrawing.Skia@0.10.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PeachDrawing.Skia&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=PeachDrawing.Skia&version=0.10.0
                    
Install as a Cake Tool

PeachDrawing.Skia

A SkiaSharp Canvas for PeachDrawing.Core: draw shapes, gradients, clips, layers, text and images with Skia, with no PDF, HTML or CSS involved and no PeachPDF reference needed. Because it is a PeachDrawing Canvas, drawing code written against PeachDrawing.Core runs on Skia unchanged, and the same code can also write PDF, SVG or a bitmap.

You supply the surface. The package never creates a window, a GPU context or a surface: it draws into an SKCanvas you already have, so it draws on the GPU exactly when the surface behind that canvas does. It is not tied to a platform: use it on Android (SKGLView, SKCanvasView), iOS, Windows, Linux or macOS.

dotnet add package PeachDrawing.Skia

Status: pre-1.0, versioned in lockstep with PeachPDF (the same number for every release); until 1.0 the API may change between releases. Targets .NET 10 and later, on SkiaSharp 3. The application referencing this package chooses the SkiaSharp native binaries (SkiaSharp.NativeAssets.*, or the platform's own package) for the platforms it ships to.

Quick start: draw into a view's SKCanvas

using PeachDrawing.Core;
using PeachDrawing.Skia;

using var context = new SkiaRenderContext();       // create once, reuse for every paint

// Inside your view's paint handler, with the SKCanvas it gives you:
using var canvas = SkiaCanvas.FromCanvas(context, skCanvas, new Rect(0, 0, 400, 300));
using var brush = canvas.GetSolidBrush(PaintColor.FromArgb(255, 220, 90, 40));
canvas.DrawRectangle(brush, 20, 20, 360, 260);

var font = context.GetFont("Arial", 24, PaintFontStyle.Regular);
if (font is not null)
    canvas.DrawString("Hello, Skia", font, PaintColor.White, new PaintPoint(40, 60), canvas.MeasureString("Hello, Skia", font));

The SKCanvas is only borrowed: disposing the SkiaCanvas pops anything still pushed and restores the canvas's save level, matrix and clip, and leaves it usable. A matrix you set beforehand (a DPI scale, a zoom, a scroll offset) is kept; the canvas draws under it.

Render a page to a bitmap

using SkiaSharp;

using var surface = SKSurface.Create(new SKImageInfo(800, 600));        // a CPU surface; a GPU-backed SKSurface works the same way
using var composer = new SkiaComposer(context, surface, widthPoints: 400, heightPoints: 300,
    new SkiaComposerOptions { Background = PaintColor.White });         // scales the page to fill the surface

composer.Canvas.DrawRectangle(context.GetSolidBrush(PaintColor.FromArgb(255, 30, 144, 255)), 20, 20, 200, 100);

composer.Finish();
await using var file = File.Create("out.png");
composer.Save(file, SkiaImageFormat.Png);                               // also Jpeg (with quality) and Webp; or composer.ToPixelBuffer()

SkiaComposer borrows the surface and never disposes it.

Text

Text is shaped by the shared PeachDrawing.Text engine by default (OpenType substitution and positioning, Arabic and Indic scripts, bidirectional text, color glyphs), so it looks the same on every platform. Register your own fonts with await context.AddFont(stream, "Family").

using var native = new SkiaRenderContext(SkiaTextEngine.Native);        // Skia's own fonts and the platform's glyph rendering
using var withShaper = new SkiaRenderContext(SkiaTextEngine.Native, textShaper: new PeachTextShaper());   // or supply your own ISkiaTextShaper (e.g. HarfBuzz)

Native-font mode is not feature complete (the guide has the table); the default engine is.

Images

SkiaImageCodec chooses what decodes an image: Auto (the default: Skia's codecs where Skia has one, PeachImage otherwise), PeachImage (the same pixels on every platform) or Native. Telling the context about the host's GRContext (context.GpuContext = grContext) uploads decoded images once and reuses the texture.

Layers, effects and blend modes

canvas.BeginLayer(new LayerOptions(...)) is an isolated SaveLayer with opacity, a blend mode and blur, drop-shadow and color-matrix effects; the 16 blend modes are SKBlendModes and conic gradients are sweep shaders. Everything else on the Canvas API (paths, gradients, clips, transforms, masks) maps directly to Skia.

AddLink, AddDestinationLink, AddCursor and AddSemanticRegion draw nothing; they are recorded in canvas.Links for your host to use:

SkiaLink? link = canvas.Links.HitTestDevice(pointer.X, pointer.Y);      // topmost link under a point in the SKCanvas's own pixels
if (link is not null) await canvas.Links.ActivateAsync(link);           // raises LinkActivating; opens through the launcher you supplied

SkiaCursorArea? cursor = canvas.Links.CursorAtDevice(pointer.X, pointer.Y);          // a CursorShape for your platform's pointer
SkiaSemanticRegion? region = canvas.Links.SemanticAtDevice(pointer.X, pointer.Y);    // role/name/level for accessibility

Document content is untrusted, so only http, https, mailto and tel addresses are opened by default (SkiaLinkOptions.AllowedSchemes widens that), and nothing is opened while painting. There is no default launcher: pass new SkiaLinkOptions { Launcher = ... } (an ISkiaLinkLauncher, for example one that starts an Android Intent) to FromCanvas, or handle Links.LinkActivating.

Lifecycle

Every native resource has one owner and a deterministic disposer: the SKCanvas and SKSurface you pass in are never disposed, a SkiaRenderContext owns the native font faces it creates (dispose it), and a canvas disposed with clips or layers still open unwinds them.

More

Sponsorship

PeachPDF is free and open source. If it saves you time, you can sponsor jhaygood86 on GitHub; sponsors can get paid support, see Sponsorship.

License

BSD 3-Clause (see LICENSE).

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PeachDrawing.Skia:

Package Downloads
PeachBrackets.Android

A .NET for Android view that shows an HTML document laid out by PeachBrackets: touch scrolling, fling and pinch zoom, links, text selection and copy, and the CSS cursor, hover and touch-action behaviour the document asks for.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.0 95 11/13/2026
0.9.26 92 11/6/2026
0.9.26-preview1 88 11/3/2026