How to assign TImageList image to TWedgeItem?

I tried this:

TImageList* MyImageList;
TWedgeItem* MyWedgeItem;
boost::scoped_ptr<Graphics::TBitmap> bmp(new Graphics::TBitmap);
bmp->PixelFormat = pf32bit;
bmp->AlphaFormat = afIgnored; // I also tried afDefined
MyImageList->GetBitmap(0, bmp.get());

The above works but loses 32-bit transparency (background is white colored instead).

How do I copy the image from TImageList to TWedgeItem and keep transparency?


You need to assign the imagelist to the polylist and then set the imageindex property of the wedge item.

Sorry but that doesn't work well.

Here is all what I tried:

1) your method - assigning TImageList to TAdvPolyPager and then setting image index. Removes the alpha transparency (it is transparent but not properly)

2) the only thing which works - setting (Picture) in the designer, so not runtime.

3) my method above - copied good but white background.

Any suggestions?

If you have transparent images (PNG's) you could also use a TPictureContainer instead.

Can you please provide a WORKING example so I don't have to assemble bits and pieces of your thoughts? That would be much more appreciated and you would be done much faster with the support that way.

The question is simple - I need to copy image from VCL TImageList (which contains all images) into a format which TWedgeItem can accept.

Direct assigning of TBitmap does not work for TAdvGDIPicture. I get exception that types are incompatible.

As long as the bitmap is copied in 32-bit format (24-bit picture + 8-bit alpha channel) and the transparency is preserved anything goes. Saving to stream, direct assigning... whatever works.

If you have added PNG's to an imagelist you also need to set the ColorDepth to cd32Bit and the DrawingStyle to dsTransparent. Then assign the ImageList to a poly list and set the ImageIndex of the TWedgeItem.

If you have the original PNG's I would suggest to use a TPictureContainer instead and use the ImageName property instead of the ImageIndex. Then there is no separate transparency handling necessary.