Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Join two *.wmf files together - adding one to the end of the other
This article has not been rated yet. After reading, feel free to leave comments and rate it.
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;
| |  | |  |
Comments:
|