Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Flexible Brotli Compression Library For Your Windows Delphi/C++ Builder VCL And FMX Apps

Intro

Most of Delphi and C++ Builder developers utilize preinstalled components and libraries to compress and decompress files. For instance, the System.Zlib which supports gzip and deflate, the System.Zip is also helpful to handle .zip archive files. Moreover, Indy’s TIdCompressorZLib which is based on Zlib. 

But that is not it. There are more different libraries based on different compression algorithms and more modern techniques, for instance, the Brotli – Brotli is similar in speed with deflate but offers more impenetrable compression. Brotli is open-sourced under the MIT License by Google. Brotli compressed files have .br extension.

To connect your Delphi or C++ Builder VCL and FMX application with the Brotli library we can rely on Brotli Compress library from WINSOFT which offers to use the Brotli library easily.

Brotli itself is free to use and distribute, but the Brotli Compress by WINSOFT is a commercial library and if you would like to use that library you should get a license!

Specifications

Installation

After downloading the Brotli from WINSOFT you should configure the library into your RAD Studio. You can follow the tutorial here that shows the steps to configure without errors.

Development

Since the Brotli itself is a whole compression library your application should have brotlilib.dll – Dynamic-link library. You will get those files within the Brotli Compressor by WINSOFT in a Library Folder.

Brotli Compressor Library has two main classes:

  1. TBrotliEncoder 
  2. TBrotliDecoder

As you can observe the TBrotliEncoder encodes and TBrotliDecoder decodes the files with the given parameters. Furthermore, the OnProgress event provides the decompression and compression progress info.

Additionally, you can set encoding quality with the Quality property.

Here is the Brotli library demonstration video that shows the demo application in action. 

These are demo projects’ UI:

DEMO UI

This is how you can encode with Brotli:

[crayon-6739c5332ef6a648753928/]

Here is how you can decode with the Brotli:

[crayon-6739c5332ef77365510541/]

As you can see this is uncomplicated and you just need to implement the file selection process and input/output streams.

Head over and check out the full WINSOFT Brotli Compression Library!

Exit mobile version