Convertir BMP -> Metafile WMF  

Enviado Por: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Fecha: 10/09/99

Truco accedido 65 veces

 



 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;