About me

Vladimir Nabokov

Books
Programming
Biochemistry
Aim | Communicate

Search
 


 
   
Letters from Terra - Life in water warmed by sunlight
 
 

     
 
 

     
Fast, automatic, and very efficient: the version three image compressor. Click here to Download.
 
 
     

Image Compression

It soon becomes apparent to anyone that has to work with a large number of small, annoying image files that laoding them seperately from disk, often in an individual process, is triesome and time consuming, and leaves room for errors in your coding. In addition, large projects soon sccumulate a large quantity of data in the form of external images, and this can increase the size of the finished product dramatically. It soon dawned on me that much of the actual data stored in my image files was redundant: 8 bits per pixel are required to store a 256 colour image, but, if like most of my images it is only constituted of ten or so separate colours, only 4 of those bits are actually required. The upshot of this realisation was the construction of my first image compressor and compiler, designed to collect all the images use don one project together into a single file, and simultaneously apply the simple compression and reduce the size of graphics in finished packages. The original image compiler was very simple and rather crude in operation: when the appropriate procedure was invoked in the graphics library, the entire contents of the library would be extracted and dumped into the memory, retaining its indexing to allow the images to be used in the engine. The advantage of this was firstly the ease of programming, which is always a powerful incentive whenever a dilemma in the coding occurs, and the speed at which the library could be read off the disk: a single Blockread command sufficed; greatly recommended this method. It soon became apparent however, that the limitation of not being able to dynamically extract seperate images for use in the program greatly complicated some of the coding, and played merry havoc with the memory requirements for even small programs. By the time the third version of the compressor was being constructed therefore, I incorporated into the compressor an index constructor, that calculated the position of each image within the library file, and stores it at the beginning of the file. This is read off the file before any sequences involving extraction are involved, allowing seperate images to be extracted and stored at specific addresses in the memory. The compressed files are given the extention .IML, standing for image library, and can be read using the graphics engines available on this site. The speed of image loading, extraction and decompression is remarkable; it is almost possible to decompress and display images onto the screen immediately, although I wouldn't recommend it in complex projects. Images can be extracted into the EMS or XMS using the graphics engines, and then referenced and displayed as normal images. The image compressor is an irreplaceable tool, and I have even began to develop a Delphi version which uses a (much) more sophisticated compression algorithm. I hope someone out there makes use of it to their advantage. Available for download with full source.

Download the Image Compressor (9 Kb, zipped) | Back to Units & Tools

 
 
Letters from Terra | Updated 15th December 2004 | By Jonathan Ayling