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

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

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

The latest RAD Studio / C++ Builder 12 comes with a lot of new features, one of them is Skia graphics library support in C++. Skia is an open-source graphic library that provides support for a variety of hardware and software platforms. Skia provides smooth 2D graphics that uses GPU efficiently. Skia supports a lot of new image formats, such as .bmp, .jpg, .gif, .gif animation, .svg, .ico, .webp, .wbmp and raw images (.arw, .cr2, .dng, .nef, .nrw, .orf, .raf, .rw2, .pef and .srw). It is very useful for handling the SVG image format which is a Scalable Vector Graphics form. In this post we explain how to use SVG images with Skia in C++ Builder.

What is Skia in modern C++?

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 to use the SVG Image format with Skia in the C++ Builder IDE?

Skia supports a lot of new image formats, such as .bmp, .jpg, .gif, .gif animation, .svg, .ico, .webp, .wbmp, and raw images (.arw, .cr2, .dng, .nef, .nrw, .orf, .raf, .rw2, .pef and .srw). If you want to use SVG image format in your applications, C++ Builder has a TSKSvg Skia component for this, first, you should drag it from the Palette window to your form design.

How To Use The SVG Image Format With Skia In C++ Builder Skia components in the C++ Builder tool palette

Then you can double click to SkSvg1 object on your form design, this will open SVG Editor. Click to Open button to select and load a SVG file. Some sample SVG examples can be found in C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\Assets folder if you installed Samples in RAD Studio 12.

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

How to use the SVG Image format with Skia in C++ Builder code?

If you want to use SVG image format in your code first you should have TSkSvg object on your form design, or you can create a new TSkSvg object as below.

Then you can read svg file as below,

If you need, you can change its Wrap mode as shown below.

If you want to make it in a single color, you can override its color to a single color like so:

SVG files may include different DOM objects in a drawing. You can do more specific operations to each of DOM objects in your SVG file. Here’s an example.

Is there a full example of how to use SVG Image format with Skia in C++ Builder code?

In C++ Builder 12, first drag a TSkSvg Skia component on your form design. Now you can load an image when the form is constructed. Here is a full simple example in C++.

If you want to see more Skia examples, please install the latest RAD Studio / C++ Builder12.1 full or trial version and check this sample in the 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. [Editor’s note: due to the way the blogging software works you will need to reverse the slashes shown in the path]

How To Use The SVG Image Format With Skia In C++ Builder 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.

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++11C++14C++17C++20Introduction to C++Learn C++Syntax

Learn Default Constructors Of Classes In Modern C++

Artificial Intelligence TechC++C++11C++14C++17Learn C++

How To Develop Special AI Activation Functions In C++?

Artificial Intelligence TechC++C++11C++14C++17Language FeatureLearn C++

Learn How To Read The WAV Waveform Audio File Format In C++

C++C++11Learn C++

What Is Assignment Operator Overloading?