Главная страница | назад





Article #17752: How do I create a bitmap from an icon?

 Question and Answer Database
FAQ2752D.txt How do I create a bitmap from an icon?
Category :VCL
Platform :All
Product :All 32 bit
Question:
How do I create a bitmap from an icon?
Answer:
Use Bitmap.Canvas.Draw to draw the icon on the Bitmap.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
TheIcon : TIcon;
TheBitmap : TBitmap;
begin
TheIcon := TIcon.Create;
TheIcon.LoadFromFile('C:\Program Files\Borland\IcoCur32\EARTH.ICO');
TheBitmap := TBitmap.Create;
TheBitmap.Height := TheIcon.Height;
TheBitmap.Width := TheIcon.Width;
TheBitmap.Canvas.Draw(0, 0, TheIcon);
Form1.Canvas.Draw(10, 10, TheBitmap);
TheBitmap.Free;
TheIcon.Free;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99