SkillAgentSearch skills...

Skia4delphi

Skia4Delphi is a cross-platform 2D graphics API for Delphi platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.

Install / Use

/learn @skia4delphi/Skia4delphi
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<p align="center"><a href="https://www.skia4delphi.org"><img src="Assets/Artwork/logo-gradient.svg" alt="Logo" height="300" width="360" /></a></p> <p> <a href="#compatibility"><img src="https://img.shields.io/static/v1?label=rad%20studio&message=xe7%2B&color=silver&style=for-the-badge&logo=delphi&logoColor=white" alt="Delphi XE7+ support" /></a> <a href="#compatibility"><img src="https://img.shields.io/static/v1?label=platforms&message=cross-platform&color=silver&style=for-the-badge&logo=delphi&logoColor=white" alt="Cross-platform support" /></a> <a href="#compatibility"><img src="https://img.shields.io/static/v1?label=applications&message=console%2C%20fmx%2C%20vcl&color=silver&style=for-the-badge&logo=delphi&logoColor=white" alt="Console, FMX, VCL support" /></a> <a href="https://t.me/skia4delphi"><img src="https://img.shields.io/static/v1?label=telegram&message=skia4delphi&color=silver&style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram group" /> <a href="https://www.youtube.com/@skia4delphi"><img src="https://img.shields.io/static/v1?label=youtube&message=skia4delphi&color=silver&style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube channel" /> </p>

Skia4Delphi is an open-source, cross-platform 2D graphics library for Delphi, utilizing the esteemed Google's Skia library.

https://user-images.githubusercontent.com/1863024/175955980-f6c57253-aaa3-4617-90dc-b0d9bf25e21b.mp4

About

Skia is an exceptional open-source library dedicated to rendering 2D text, geometries and images, with a focus on precision, superior quality and high performance. It offers versatile APIs compatible with a wide range of hardware and software platforms.

Google's Skia Graphics Library functions as the graphics engine for numerous products, including Google Chrome, Chrome OS, Android, Flutter, Xamarin, Mozilla Firefox, Firefox OS, and more.

Features

  • Canvas 2D and Text Layout;
  • CPU software rasterization;
  • GPU-accelerated rendering;
  • Right-to-Left rendering;
  • SVG rendering and creation;
  • PDF output;
  • Runtime effects;
  • Shading language;
  • Shaders, mask and color filters;
  • Image and path effects;
  • Animated image player; (Lottie, GIF, WebP)
  • Image codecs; (bmp, gif, ico, jpg, png, wbmp, webp and raw images) and much more...

FMX render replacement

Using the Skia4Delphi library it is possible to override Firemonkey's graphic engine so that it can use Skia as its default Canvas. With that, your Firemonkey application will automatically:

  • Draw with antialiasing on any platform (the drawing quality is based on the Form.Quality property);
  • Increase the overall graphics performance of your application by up to 50% (even drawing with higher quality);
  • Resize images with better quality (also based on Form.Quality);
  • Support Right-To-Left text rendering;
  • Fix dozens of inconsistencies in drawings (especially in corners and strokes, such as dashes, and in texts with special emojis);
  • Increase the performance of the library in general (controls, drawings, among others...).

Learn more...

Summary

Using the library

Prerequisites

Install

You can install Skia4Delphi in 3 ways:

  • Setup (recommended)

    Download the setup of latest release and install it.

    <p><img src="Assets/Documents/installation.png" width="511" alt="Skia4Delphi Installation" /></p>
  • Embarcadero's GetIt (RAD Studio > Tools > GetIt Package Manager...)

    <p><img src="https://user-images.githubusercontent.com/11139086/214978288-11c87e9e-7a8b-4686-82c0-5922676d26df.png#gh-light-mode-only" width="511" alt="GetIt" /></p> <p><img src="https://user-images.githubusercontent.com/11139086/214978346-c67bb0f6-ec96-4833-a1e4-7ee39d620e82.png#gh-dark-mode-only" width="511" alt="GetIt" /></p>
  • Chocolatey package manager

    choco install skia4delphi
    

Remarks

  1. Manual installation is possible, although it is not recommended; Learn more...
  2. The pre-built Skia binaries were included in the source, but you can easily recompile them; Learn more...

Enable Skia

After install the Skia4Delphi, just right click in your application project and click Enable Skia.

Menu Menu

Tip

To improve the quality and performance of FMX drawings, the replacement of the the FMX graphics engine with the Skia4Delphi render is automatically enabled. Learn more...

Examples

In this section you will find some examples of using Skia4Delphi, it works in Console, FMX, and VCL applications. The code below is common code among all the examples in this section:

uses
  System.Skia;

type
  TSkDrawExampleProc = reference to procedure(const ACanvas: ISkCanvas; const ADest: TRectF);

procedure DrawExample(const AWidth, AHeight: Integer; const ADrawProc: TSkDrawExampleProc);
begin
  var LSurface := TSkSurface.MakeRaster(AWidth, AHeight);
  LSurface.Canvas.Clear(TAlphaColors.Null);
  ADrawProc(LSurface.Canvas, RectF(0, 0, AWidth, AHeight));
  LSurface.MakeImageSnapshot.EncodeToFile('output.png');
end;

Basic usage

The code below demonstrate how to draw shapes:

DrawExample(256, 256,
  procedure (const ACanvas: ISkCanvas; const ADest: TRectF)
  begin
    var LPaint: ISkPaint := TSkPaint.Create;
    LPaint.AntiAlias := True;

    LPaint.Color := $FF4285F4;
    var LRect := TRectF.Create(PointF(10, 10), 100, 160);
    ACanvas.DrawRect(LRect, LPaint);

    var LOval: ISkRoundRect := TSkRoundRect.Create;
    LOval.SetOval(LRect);
    LOval.Offset(40, 80);
    LPaint.Color := $FFDB4437;
    ACanvas.DrawRoundRect(LOval, LPaint);

    LPaint.Color := $FF0F9D58;
    ACanvas.DrawCircle(180, 50, 25, LPaint);

    LRect.Offset(80, 50);
    LPaint.Color := $FFF4B400;
    LPaint.Style := TSkPaintStyle.Stroke;
    LPaint.StrokeWidth := 4;
    ACanvas.DrawRoundRect(LRect, 10, 10, LPaint);
  end);

This code results in the output below:

<p><img src="Assets/Documents/example1.svg" width="192" height="192" alt="Example 1" /></p>

Learn more...

PDF

With Skia4Delphi it is possible to create PDF documents and draw anything on them, from text to images. The example below demonstrates how to create an PDF document and draw an SVG inside it:

  var LSVGDOM := TSkSVGDOM.MakeFromFile('Samples\Demo\Assets\lion.svg');
  var LSize := TSizeF.Create(600, 600);
  LSVGDOM.SetContainerSize(LSize);

  var LDocumentStream := TFileStream.Create('output.pdf', fmCreate);
  try
    var LDocument := TSkDocument.MakePDF(LDocumentStream);
    try
      var LCanvas := LDocument.BeginPage(LSize.Width, LSize.Height);
      try
        // Draw anything here with Skia canvas
        LSVGDOM.Render(LCanvas);
      finally
        LDocument.EndPage;
      end;
    finally
      LDocument.Close;
    end;
  finally
    LDocumentStream.Free;
  end;

This code results in the output below:

<p><img src="Assets/Documents/lion.svg" width="200" height="200" alt="Lion" /></p>

Codecs

The Skia4Delphi library supports many image formats. See below the list:

  • Supported formats for decoding

    | Image Format | Extensions | | ------------------------------ | ----------- | | Bitmap | .bmp | | GIF | .gif | | Icon | .ico | | JPEG | .jpg, .jpeg | | PNG | .png | | Raw Adobe DNG Digital Negative | .dng | | Raw Canon | .cr2 | | Raw Fujifilm RAF | .raf | | Raw Nikon | .nef, .nrw | | Raw Olympus ORF | .orf | | Raw Panasonic | .rw2 | | Raw Pentax PEF | .pef | | Raw Samsung SRW | .srw | | Raw Sony | .arw | | WBMP | .wbmp | | WebP | .webp |

    Note: Raw images are limited to non-windows platforms

  • Supported formats for encoding

    | Image Format | Extensions | | ------------ | ----------- | | JPEG | .jpg, .jpeg | | PNG | .png | | WebP | .webp |

About WebP

WebP is a modern image format that provides superior lossless and lossy compression for images. WebP lossless images are 26% smaller in size compa

Related Skills

View on GitHub
GitHub Stars768
CategoryDevelopment
Updated18d ago
Forks154

Languages

Pascal

Security Score

100/100

Audited on Mar 7, 2026

No findings