I have a PNG image that i'm trying to load into a TImageList
at design-time:
I have an image list, which i then try to open my png:
Once added, the image that appears is not correct:
What steps in opening a file am i missing?
Any other variations anyone would like to see?
The issue was that I was using a function contained in the GraphicEx library:
procedure Stretch(NewWidth, NewHeight: Cardinal; Filter: TResamplingFilter;
Radius: Single; Source: TBitmap);
The call to this function is abstracted away inside a ResizeGraphic helper function.
The problem is that GraphicEx
also has it's own PNG
implementation:
TPNGGraphic = class(TGraphicExGraphic)
which is then registered at runtime as an available file format:
initialization
RegisterFileFormat('png', gesPortableNetworkGraphic, '',
[ftRaster], False, True, TPNGGraphic);
We use some custom Delphi components.
Some of these components directly or indirectly import a reference to GraphicEx
. This then means that GraphicEx
is taking over handling of the PNG
file type away from whatever class exists inside the IDE at design.
The solution was to define away all the RegisterFileFormat
lines in the initialization
section of GraphicEx.pas
{$ifdef PortableNetworkGraphic}
RegisterFileFormat('png', gesPortableNetworkGraphic, '', [ftRaster], False, True, TPNGGraphic);
{$endif}
and then re-build all my runtime and design-time packages.
Once that was done, and the IDE restarted:
Note: Any code released into public domain. No attribution required.