DelphiFAQ Home Search:
General :: Windows :: Programming :: Windows with Delphi :: Windows Graphics
Graphics programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Join two *.wmf files together - adding one to the end of the other

Question:

I need to join two *.wmf files together - adding one metafile to the end of the other metafile.

Answer:

You need ot 'play back' those meta files in the order desired into the canvas of the new to be created meta file. The code below plays 'w1.wmf' and the 'w2.wmf' and saves it under 'w_merged.wmf'.

  MetaFile1 := TMetaFile.Create;
   MetaFile2 := TMetaFile.Create;
   DestMetaFile := TMetaFile.Create;
   try
     MetaFile1.LoadFromFile('w1.wmf');
     MetaFile2.LoadFromFile('w2.wmf');
     DestMetaFile.Width := Max(MetaFile1.Width, MetaFile2.Width);
     DestMetaFile.Height := MetaFile1.Height + MetaFile2.Height;
     MetaFileCanvas := TMetaFileCanvas.Create (DestMetaFile, 0);
     try
       MetaFileCanvas.Draw (0, 0, MetaFile1);
       MetaFileCanvas.Draw (0, MetaFile1.Height, MetaFile2);
     finally
       MetaFileCanvas.Free;
     end;
     DestMetaFile.SaveToFile('w_merged.wmf');
   finally
     MetaFile1.Free;
     MetaFile2.Free;
     DestMetaFile.Free;
   end;
 

Generated 8:02:10 on Nov 20, 2017