⤷ Put bitmap to metafile

This example shows, how to work with metafiles. For example, how to put some bitmap to metafile. Use standard methods and properties of TMetaFile and TMeFileCanvas types.

procedure TForm1.Button1Click(Sender: TObject);
var
  MyBitmap: TBitmap;
  MF: TMetaFile;
  MFCanvas: TMetaFileCanvas;
begin
  MyBitmap:=TBitmap.Create;
  MyBitmap.LoadFromFile('TestBMP.bmp');
  MF:=TMetaFile.Create;
  MFCanvas:=TMetafileCanvas.Create(MF, 0);
  MFCanvas.Draw(0, 0, MyBitmap);
  MFCanvas.Free;
  MyBitmap.Free;
  MF.SaveToFile('TestEMF.emf');
  MF.Free;
  Image1.Picture.LoadFromFile('TestEMF.emf');
end;
More for developers