size : 692
uploaded_on : Wed Apr 7 00:00:00 1999
modified_on : Wed Dec 8 14:03:38 1999
title : Resizing TBitmap to fit in TImageList
org_filename : resizeBmp.txt
author : Robert Barr
authoremail : barr@unm.edu
description : How to resize a bitmap to be added to an image list
keywords :
tested : not tested yet
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-graphics
__END_OF_HEADER__
{ Well since TImageList is a collection of same-sized images you'll just
have to make sure all the newly inserted bitmaps are equal the Height
and Width of the imagelist.
How about something like...
}
...
var
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
try
// Set H&W of Bitmap to match ImageList
Bitmap.Height := ImageList1.Height;
Bitmap.Width := ImageList1.Width;
// StretchDraw Bitmap with some bitmap, in the case Image1.Picture.Bitmap
with Bitmap do
Canvas.StretchDraw(Rect(0, 0, Width, Height),Image1.Picture.Bitmap);
// Add Resized/Scaled bitmap to image list
Imagelist1.Add(Bitmap, nil);
finally
Bitmap.Free;
end;
end;