[fpc-pascal] FCL-Image and OS/2 BMP support

Michael Van Canneyt michael at freepascal.org
Fri Apr 5 12:07:50 CEST 2013

On Fri, 5 Apr 2013, Graeme Geldenhuys wrote:

> Hi,
> Having had a quick look at the FPReadBMP.pp unit, the only BMP format
> FCL-Image supports is the Windows BMP format. I need to read OS/2 BMP
> files too.
> Here is a very brief comparison between the two formats. Note that OS/2
> Bitmaps can be larger, multiple images per file, different compression
> algorithms, different file headers etc.
> OS/2 Bitmap:
>  http://www.fileformat.info/format/os2bmp/egff.htm
> Windows Bitmap:
>  http://www.fileformat.info/format/bmp/egff.htm
> I'm doing the work for fpGUI's DocView, but would like to share the code
> with FPC too. What would be the suggested way of doing this?
> 1) extend the existing FPReadBMP.pp unit. This could be messy.
> 2) create a whole new unit specific to OS/2 Bitmaps.
> I would opt for (2). But that raises another problem, but probably not
> relevant to others here. If option (2) is used, your application can't
> simply assume a *.bmp can be read with FPReadBMP, it needs to check the
> file header first, then determine the correct unit & class to use to
> read the bitmap.

That's why, unfortunately, I think 1) is better.

A second problem is the 'multiple images per file'.

You will need an image number when loading. 
That will need a change in the reader or in TFPCustomImageHandler.
(a property, default set to 0, so it reads the first image (zero based))


More information about the fpc-pascal mailing list