Hide Comments
Hide Comments

Use a TRSSVGImageList to manage multiple SVGs

Comments (0)

The TRSSVGImageList component provides a powerful means to manage a list of SVGs in your application.  It embeds every SVG within the image list (simplifying deployment) and re-renders the SVGs as needed.  Like a traditional TImageList, multiple controls can use the same TImageList, either different items or the same item, and it is all managed automatically for you.

 

In VCL, you can change the TRSSVGImageList Width and Height at any time and the SVGs will be re-rendered.

 

With the FMX platform, the TRSSVGImageList is even more powerful.  It defines a TImageList composed entirely of SVGs to enable compact, graphical support of different screen resolutions and densities.

 

As you know, FireMonkey is a multi-platform framework (Windows, iOS, Mac OS X, and Android), and therefore FireMonkey applications work on devices having different screen densities and resolutions. Embarcadero recommends using FireMonkey multi-resolution bitmaps so that your images and icons in FireMonkey applications will appear correctly in different densities and resolutions (Windows, iOS, Mac OS X, and Android). However, a multi-resolution bitmap is a collection of bitmaps providing the same image (probably), each designed for a different scale to provide the same look irregardless of the resolution of the device the app is running on. This means that multiple copies of the same image can be embedded in your app (Embarcadero recommends at least two scales for iOS, regular and retina, and four or more on Android) - most of these copies are unused as they are intended for a different scale than the one your app is running on - potentially wasting lots of disk and memory space.

 

Not only do you not even need to generate all these extra resolution images with the TRSSVGImageList component, but you don't need to store them either.  The TRSSVGImageList component solves this problem by creating a TImageList composed entirely of SVGs. For each SVG, you specify the sizes that the SVG should take at each screen scale. The TRSSVGImageList component generates, at run-time, bitmaps only for the current screen scale, potentially saving lots of space.  Because the SVG is buffered as a bitmap for the current screen scale, refreshes are extremely fast after the initial setup.

 

It is generally not recommended to use SVGs with text on non-Windows platforms unless the specified Width and Height are large. The FMX library provides poor text quality when writing to offscreen bitmaps, which is what the TRSSVGImageList does, on these platforms.

Comments (0)

RiverSoftAVG SVG Component Library (RSCL) © 2013-2016, Thomas G. Grubb