Earlier we reviewed BMP, JPEG, TIFF, and GIF in the article about various graphic image formats. It remains to discuss the last most common format - PNG. Currently, Portable Network Graphics (PNG) is one of the best-known and most commonly used file formats.
Why did it happen that this format is popular in the world? It’s simple. A wide range of colors, gamma correction, saving with or without a background. There are really many convenient options because PNG can save information without losing image quality. It is most often used for viewing, compressing pictures, and editing/creating graphics.
You can open PNG in almost every imaginable program, which is why in 1996 PNG became a great alternative to GIF (Graphics Interchange Format) and, to some extent, it replaced much more complicated TIFF (Tagged Image File Format).
Initially, it was called PBF (Portable Bitmap Format), but after improvements, the W3C consortium reviewed the specification and approved it as the optimal network format.
PNG supports three types of bitmaps:
- grayscale image (color depth 16 bits);
- color indexed image (color depth 24 bits);
- full-color image (color depth 48 bits).
The format has many advantages over the GIF format. I will give a few examples.
1) It can store graphic information in a compressed form, no matter how many times you save it or leave it in intermediate editing. Your work is guaranteed to remain the same quality.
2) It allows you to include metadata or save copyright information.
3) PNG has a very small image size.
4) It uses the open, non-proprietary Deflate compression algorithm.
Fast Report software products for macOS, Linux, and Windows can convert, create, save, and export images of this resolution. In the report generator for Delphi, you can save a document even in PNG format.
Export the report from the preview
Let's say that you have already created your report and launched the preview. Select the PNG format from the export window. A window will appear with the export settings. For example, you can save all pages, the current page, or specify pages.
A detailed description of PNG export settings.
Monochrome - images in shades of black;
Crop pages - cropping pages;
JPEG quality - setting the quality of a graphic object (will not be available due to the specifics of the format);
Resolution (dpi) - resolution in dots per inch;
Open after the export - automatic opening of the document immediately after saving.
It is also possible to save the file to the computer's memory, upload it to the cloud, and send it by e-mail or FTP.
How to save to PNG from Delphi/C++Builder/Lazarus code?
Comparison of PNG sizes with other formats
Let's make a small comparison of the weight of the final files when exporting the report. We worked with a small report with various measuring scales.
PNG - 26,7 KB; BMP - 6,80 MB; JPEG - 78,0 KB; TIFF - 2,55 MB; GIF - 20,9 KB.
You may notice that the PNG format is larger than the GIF when exported. This happened because the original resolution was kept, and the GIF lost some quality when saving to PNG.
Thus, the PNG format is best used when working with graphic images, and GIF is used for animations.
The other formats are great for other purposes. For example:
- BMP is most efficient when saving only raster images;
- JPEG is used to save photos, email graphics, and large images such as advertising banners;
- TIFF is used in scanning and OCR. Often, these format files are used in faxing.
Let's sum up. It is very easy and convenient to export any created, opened, or edited object from FastReport VCL to Portable Network Graphics (PNG). This format is perfect for many purposes, whether it is creating drawings of embroidery patterns or drawings for turning parts. Fast Reports products will help you to implement all of this.