The architecture around the Png imagelist is however a bit different than that of Delphi, and may lead to confusion, especially when trying to access it from code.
This article shows you how to use and manipulate the Png imagelist from code..
Update: New Delphi versions (from 2009) offer PNG out of the box, in which case you manipulate the TImageList instead of TPngImageList. In that case the info in this post is deprecated.
FImages: TPngImageList; // example var with imagelist, for the example sake we suppose its already created
procedure AddPng(aPngImage: TStream);
var
col: TImageCollectionItem;
imgcol: TPngImageCollection;
begin
imgcol := TPngImageCollection.Create(nil);
imgcol.Items.Assign(FImages.PngImages);
col := imgcol.Items.Add;
aPngImage.Position := 0;
col.PngImage.LoadFromStream(aPngImage);
FImages.Width := col.PngImage.Width;
FImages.Height := col.PngImage.Height;
ItemHeight := FImages.Height + 2;
FImages.PngImages.Assign(imgcol.Items);
col.Name := 'PngImage' + IntToStr(FImages.PngImages.Count - 1);
end;
Geen opmerkingen:
Een reactie posten