According to my previous question with the help of Cosmin Prund, I found how to stretch Image and add to ImageList:
procedure LoadDatasetImagesToImageList;
var
StretchedBMP: TBitmap;
MS: TMemoryStream;
begin
ImageList.Clear;
ItemsDts.First;
StretchedBMP := TBitmap.Create;
try
// Prepare the stretched bmp's size
StretchedBMP.Width := ImageList.Width;
StretchedBMP.Height := ImageList.Height;
// Prepare the memory stream
MS := TMemoryStream.Create;
try
ImageBitmap:= TBitmap.Create;
try
while not ItemsDts.Eof do
begin
if not ItemsDtsPicture.IsNull then
begin
MS.Size := 0;
ItemsDtsPicture.SaveToStream(MS);
MS.Position := 0;
ImageBitmap.LoadFromStream(MS);
// Stretch the image
StretchedBMP.Canvas.StretchDraw(Rect(0, 0, StretchedBmp.Width-1, StretchedBmp.Height-1), ImageBitmap);
ImageList.Add(StretchedBmp, nil);
end;
ItemsDts.Next;
end;
finally
ImageBitmap.Free;
end;
finally
MS.Free;
end;
finally
StretchedBMP.Free;
end;
Now the problem is that inserted Image is not transparent in ImageList. When displaying Items in a TListview, images are not transparented. But when adding images normally (without stretching and using StretchedBMP variable) images are transparent.
PS: the link to the previous question is: Add stretched image to ImageList in Delphi