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

Sven Barth pascaldragon at googlemail.com
Fri Apr 5 14:31:15 CEST 2013


Am 05.04.2013 12:07, schrieb Michael Van Canneyt:
>
>
> 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))
With support for multiple images per file we could add *.ico support to 
fcl-image as well (currently this is implemented in the LCL). And this 
could also benefit *.gif :)

Regards,
Sven



More information about the fpc-pascal mailing list