C++C++17Learn C++

How To Use Skia in C++ Builder 12?

How To Use Skia in C++ Builder 12

The latest RAD Studio / C++ Builder 12 comes with fully integrated Skia graphics library support in C++ and throughout the IDE. Skia is an open-source graphic library that provides support for a wide variety of hardware and software platforms. Skia is sponsored and managed by Google but is available for use by anyone under the BSD Free Software License. Skia provides smooth 2D graphics that uses GPU efficiently. In this post we explain how to use Skia in C++ Builder.

What is Skia in modern C++?

How To Use Skia in C++ Builder 12

Skia is an open-source graphic library that provides support variety of hardware and software platforms. Skia is sponsored and managed by Google but is available for use by anyone under the BSD Free Software License. Mainly designed for Google Chrome and ChromeOS, Android, Flutter, Mozilla Firefox and Firefox OS, and many other products. The core components are done by the Skia development team, but they consider contributions from any source.

How can we use Skia in C++ Builder 12 project code?

First, you need C++ Builder 12.1, or you need Skia4Delphi component installed on C++ Builder 11.x. Skia is a new 2D render feature of RAD Studio / C++ Builder 12.1. It comes with Skia.Package.FMX, Skia.Package.RTL, Skia.Package.VCL. package libraries officially.

If you want to use Skia in your C++ Builder applications, you need to download the latest RAD Studio / C++ Builder. Then create a new C++ Builder FMX application or VCL application or open your project and you just need to enable Skia by right-clicking on your project in the Project window in C++ Builder. You don’t need to install any 3rd party components, after the RAD Studio 12.1 version, it is completely included in the built-in libraries.

How To Use Skia in C++ Builder 12

In addition to Enabling Skia as above , it is recommended to add FMX.Skia.hpp header to your Project.cpp as shown below.

It is recommended to set true GlobalUseSkia, GlobalUseVulkan and set false GlobalUseSkiaRasterWhenAvailable flags inyour Project.cpp like so:

Is there a simple example to Skia in C++ Builder 12?

Now, we can back to our Form to use Skia graphics. Let’s use its amazing Shader feature to create a gradient background. To do this follow these steps.

1. Drag TSkPainBox component from the Pallette window

How To Use Skia in C++ Builder 12

2. Select SkPainBox1, in Object Inspector on the left side, goto Events tab and double click to OnDraw() event,

How To Use Skia in C++ Builder 12

this will create OnDraw() event procedure in your code which is declared in your header.

3. Modify inside as given example below,

more securely, for any graphical issues we can save canvas state and we can use try{ } and __finally{ } as shown below.

then run your application, here is the result:

How To Use Skia in C++ Builder 12

Is there a full example of how to use Skia in C++ Builder 12?

Here is the full code of this simple Skia example that uses Shaders of GPU to draw a gradient. Very simple and amazing!

If you want to see more examples, please install the latest RAD Studio / C++ Builder12.1 full or trial version and check this sample in Samples folder:
C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\CPP\Multi-Device Samples\Skia4Delphi project. It has many examples that runs different Skia graphical examples.

How To Use Skia in C++ Builder 12 C++ logo

C++ Builder is the easiest and fastest C and C++ compiler and IDE for building simple or professional applications on the Windows operating system. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17C++20Learn C++NumericsSyntax

How To Compute The Greatest Common Divisor And Least Common Multiple in C++?

C++C++17Language FeatureLearn C++

How To Use Skia Shader SkSL Shading Language Code in C++ Builder?

Artificial Intelligence TechC++C++17C++20Learn C++

How To Create Simple Generative AI Code In C++

C++C++17Language FeatureLearn C++

How To Use The SVG Image Format With Skia In C++ Builder