Convert Icon to bmp-file

Posted in Algorithms

Use standard properties of TBitmap class:

procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap: TBitmap;
begin
  Image1.Picture.Icon:=Application.Icon;
  Bitmap:=TBitMap.Create;
  with Bitmap do
  begin
    PixelFormat:=pf24bit;
    Height:=Application.Icon.Height;
    Width:=Application.Icon.Width;
    Canvas.Draw(0, 0, Image1.Picture.Graphic);
  end;
  if SaveDialog1.Execute then
    Bitmap.SavetoFile(SaveDialog1.FileName);
end;