Please enable JavaScript to view this site.

KOL/MCK - User Guide

Support for working with JPEG images is provided by the JpegObj module, the code for which is based on the source code provided by the Independent JPEG Group. Most of the code is precompiled and delivered in the form of object files, so, unfortunately, I cannot 100% guarantee that this code is error-free. Nevertheless, the experience of using this module in my applications shows a rather significant resistance of its code to faulty data.

 

The technique for working with JPEG images is not much more complicated than with bitmap images (TBitmap). In order to load an image, one of the methods of loading from a file or stream is called for the TJpeg object. Before an image can be drawn on the canvas or assigned to a bitmap object (TBitmap), a decoding procedure must be performed (for which the DIBNeeded method is explicitly or implicitly called), during which the JPEG image is decoded and restored to an internal TBitmap object.

 

Either immediately after decoding or before decoding starts, the ConvertCMYK2RGB property must be set to TRUE, otherwise, if the JPEG image is CMYK encoded, the colors will be incorrect. However, if you are sure that images in this format will not come across to your application, you can leave this property untouched and save a few kilobytes of code.

 

In the process of loading and decoding large images (which can be decoded for quite a long time - up to several seconds), it makes sense to use the OnProgress event to display the progress of the loading process (or finished parts of the decoded display), and be able to interrupt the operation before the entire decoding operation is completed. if there is a need for it.

 

If you need to download not the image itself, but its reduced copy, then the JPEG format has special tools for accelerating the loading of such thumbnails. It is enough to set the required scale to the Scale property (the minimum possible value of jsEighth, which corresponds to 1/8 of the original size).

 

A TJpeg object allows you to reverse-convert a bitmap to JPEG and save it to a file or stream. To do this, simply assign the object's Bitmap property some other bitmap of the TBitmap type (using the ': =' operation, not the Assign! Method), and then execute the appropriate save method, for example, SavetoFile. Compression is performed immediately before the save is performed - automatically, or it is possible to call the Compress method at the desired moment. In this case, it is also possible to control the degree of compression by assigning a pre-required value to the CompressionQuality property (a number in the range from 1 to 100). When encoding an image, the OnProgress event can also be used to indicate progress and possible interruption of the operation.

 

If the application does not call methods that compress and save the image, then this saves about 30KB of code. In this case, the increase in the size of the application will be about 50K. If both upload and download are used, it is easy to calculate that the growth in the size of the application will be about 80K. By the way, this value for KOL applications cannot be considered negligible. I also cite these figures in order to make it clear that, for example, you should not store graphic images in resources in JPEG format if there are not many of them and they are small: the fat decoder code of such resources will eat up the size savings. Not to mention, JPEG is a lossy compression format, meaning the image is distorted compared to the original.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC