简体   繁体   中英

How to put PNG into TImageList?

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?

Edit: Lets try some more files

在此处输入图片说明在此处输入图片说明

在此处输入图片说明在此处输入图片说明

在此处输入图片说明在此处输入图片说明

Edit: More settings

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

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);

Enter Custom Controls

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM