Skip to content

Add an option to prevent image format readers/writers to be registered as default fpc image handlers #274

@DomenicoMammola

Description

@DomenicoMammola

Hello,
I've found that if you write a console application (no lcl) that use BGRABitmap library and someother standard fpc library that uses fcl-image (fpPdf for example), some errors like '"Portable Network Graphics" already has a reader class' could be issued when the application starts.
Look at the enclosed project for a sample.
This should be caused by the initialization code of the unit BGRAReadBMP, BGRAWriteBMP, BGRAReadPng, BGRAWritePNG that sometimes could be executed before the inizialization code of the standard fpc images-related units.
Surely there could be some workarounds:

  • in a really really simple situation, like the enclosed project, I can change the order of the units in the uses clauses
  • I can add in my project first uses clauses the standard fpc units: FPReadJPEG, FPReadPNG, FPReadBMP (and the writers too if needed)

However there could be a smarter solution such as to add, maybe in the BGRABitmapTypes unit, a global variable tryToReplaceFPCImageReadersWriters of type boolean and then to use it in the initializalization code of the BGRABitmap units, for example:

initialization
  BGRARegisterImageReader(ifPng, TBGRAReaderPNG, tryToReplaceFPCImageReadersWriters, 'Portable Network Graphics', 'png');

This could be a valid option?
If you agree, I can make a pull request with the changes for you convenience.
Thanks for your amazing library,

Domenico

testcase.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions