I'm trying to load PNG images from a resource file into an imagelist.
The rc file looks like this and compiles well into an res file:
IDR_BLANK RCDATA ".\..\img\blank.png"
IDR_FLAGRED RCDATA ".\..\img\flag_red.png"
IDR_FLAGYELLOW RCDATA ".\..\img\flag_yellow.png"
IDR_FLAGGREEN RCDATA ".\..\img\flag_green.png"
IDR_FLAGBLUE RCDATA ".\..\img\flag_blue.png"
IDR_FLAGORANGE RCDATA ".\..\img\flag_orange.png"
IDR_FLAGPINK RCDATA ".\..\img\flag_pink.png"
IDR_FLAGPURPLE RCDATA ".\..\img\flag_purple.png"
IDR_COMMENT RCDATA ".\..\img\comment.png"
IDR_COMMENTS RCDATA ".\..\img\comments.png"
I tried to load those images using this coding:
FImageList.ResInstLoad(HInstance, rtBitmap, 'IDR_BLANK', clLime);
But it seems that no images are present, at least my listview doesn't show
any. Is this due to the fact the imagelist cannot handle PNG images?
--
cu,
Michael
if you ask for rtBitmap, the resource type must be BITMAP, not RCDATA.
but that won't help you with PNG files because the image list cannot
handle them.
you need to load the PNG resources yourself using a TPngImage (e.g. from
pngimage.sf.net) and convert it to a bitmap before adding it to the
list. alternatively, you could use TPngImageList from
www.thany.org/article/32/PngComponents.
--matthias
> I'm trying to load PNG images from a resource file into an imagelist.
>
> The rc file looks like this and compiles well into an res file:
> IDR_BLANK RCDATA ".\..\img\blank.png"
> ...
>
> I tried to load those images using this coding:
> FImageList.ResInstLoad(HInstance, rtBitmap, 'IDR_BLANK', clLime);
They are not bitmaps - they are PNGs. So you need to create a PNG, load the PNG
from resource, then transfer to ImageList:
PNG := TPngObject.Create;
PNG.LoadFromResourceID(...);
ABitmap.Assign(PNG);
FImageList.Add(ABoitmap, nil);