TImageList 32bit icons with multiple images looks bad?

104 Views Asked by At

I'm new to C++ Builder. I just added my normal icons to a TImageList that is set to 32bit, and it looks bad (when looking in the TImageList via IDE or in the Control it's used, like a TTreeView). The icons have multiple sizes, one such has 48x48, 32x32, 24x24, 16x16, all RGB/A. The 32x32 TImageList looks a little better than the 16x16 TImageList, it's almost like it added the first size found 48x48 and scaled it down instead of picking the size that matches the TImageList, but that would be a major limitation and not make any sense. I must be doing something wrong? Is there a solution to ensure they look good?


EDIT:

I did a test by removing all items from the 16x16 TImageList and added this (after adding a .rc file to the project, of course):

void __fastcall TSharedDataModule::DataModuleCreate(TObject *Sender)
{
     for (UINT i=IDI_USER_ICON_START; i<=IDI_USER_ICON_END; i++) {
         TIcon *icon = new TIcon;
         icon->Handle = reinterpret_cast<HICON>(LoadImageW(HInstance, MAKEINTRESOURCE(i), IMAGE_ICON, ImageList16->Width, ImageList16->Height, 0));
         ImageList16->AddIcon(icon);
         delete icon;
    }
}

And the icons look great in the TTreeView, so it does look like a bug or missing feature in the IDE to load the correct image from .ico files.

I did notice my TDBGrid icons are now pure black, so I'll have to deal with that next.

Is that the answer, or am I missing something I need to do in the IDE?

1

There are 1 best solutions below

0
Eugene Balabuev On

Contrary to the statement in Delphi documentation, TImageList cannot handle 32bit semi-transparent images at design-time.

https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Controls.TImageList

PNG or BMP (32-bit, premultiplied or not) - will produce the bug. Following is an example of three images (non-premultiplied bmp, premultiplied bmp, png) on different backgrounds:

On clBtnFace background

On clGreen background

It's a long lasting bug. It exists in all Delphi versions including the latest Delphi 11.