Mega Code Archive

 
Categories / Delphi / VCL
 

Dynamically drawing a transparent image

Question: How do I use a TImageList component to dynamically draw a transparent image? Answer: The following example demonstrates the dynamic creation of a TImageList component used to draw a transparent bitmap. Example: procedure TForm1.Button1Click(Sender: TObject); var bm : TBitmap; il : TImageList; begin bm := TBitmap.Create; bm.LoadFromFile('C:\DownLoad\TEST.BMP'); il := TImageList.CreateSize(bm.Width, bm.Height); il.DrawingStyle := dsTransparent; il.Masked := true; il.AddMasked(bm, clRed); il.Draw(Form1.Canvas, 0, 0, 0); bm.Free; il.Free; end;