Convert BMP -> Metafile WMF  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 10/09/99

Tip accessed 544 times

 



 procedure TForm1.Button2Click(Sender: TObject);

   procedure BmpToWmf (BmpFile,WmfFile:string);
   var
      MetaFile  : TMetaFile;
      MFCanvas  : TMetaFileCanvas;
      BMP       : TBitmap;
   begin
     {Creamos temporales}
     {Create temps}
     MetaFile := TMetaFile.Create;
     BMP      := TBitmap.create;

     {Cargamos el BMP}
     BMP.LoadFromFile(BmpFile);

     {Igualemos tamaņos}
     {Equalizing sizes}
     MetaFile.Height := BMP.Height;
     MetaFile.Width := BMP.Width;

     {Creamos un canvas para el MetaFile}
     {Create a canvas for the Metafile}
     MFCanvas:=TMetafileCanvas.Create(MetaFile, 0);
     with MFCanvas do
     begin
       {Dibujamos el BMP en el canvas}
       {Draw the BMP into canvas}
       Draw(0, 0, BMP);
       {Liberamos el Canvas}
       {Free the Canvas}
       Free;
     end;
     {Liberamos el BMP}
     {Free the BMP}
     BMP.Free;

     with MetaFile do
     begin
       {Grabamos el MetaFile}
       {Save the Metafile}
       SaveToFile(WmfFile);
       {Lo liberamos}
       {Free it...}
       Free;
     end;
   end;

 begin
   BmpToWmf('c:\kk\kk.bmp','c:\kk\kk.wmf');
 end;