首页  编辑  

BMP<-->WMF

Tags: /超级猛料/Picture.图形图像编程/图片转换/   Date Created:

WMF 格式转换为BMP格式

--------------------------------------------------------------------

procedure WmfToBmp(FicheroWmf,FicheroBmp:string);  

var  

 MetaFile:TMetafile;  

 Bmp:TBitmap;  

begin  

 Metafile:=TMetaFile.create;  

 {Create a Temporal Bitmap}  

 Bmp:=TBitmap.create;  

 {Load the Metafile}  

 MetaFile.LoadFromFile(FicheroWmf);  

 {Draw the metafile in Bitmap's canvas}  

 with Bmp do  

 begin  

  Height:=Metafile.Height;  

  Width:=Metafile.Width;  

  Canvas.Draw(0,0,MetaFile);  

  {Save the BMP}  

  SaveToFile(FicheroBmp);  

  {Free BMP}  

  Free;  

 end;  

 {Free Metafile}  

 MetaFile.Free;  

end;  

---------------------------------------------------------------------

3.BMP格式转换为WMF格式

---------------------------------------------------------------------

procedure BmpToWmf (BmpFile,WmfFile:string);  

var  

 MetaFile : TMetaFile;  

 MFCanvas : TMetaFileCanvas;  

 BMP : TBitmap;  

begin  

 {Create temps}  

 MetaFile := TMetaFile.Create;  

 BMP := TBitmap.create;  

 BMP.LoadFromFile(BmpFile);  

 {Igualemos tama駉s}  

 {Equalizing sizes}  

 MetaFile.Height := BMP.Height;  

 MetaFile.Width := BMP.Width;  

 {Create a canvas for the Metafile}  

 MFCanvas:=TMetafileCanvas.Create(MetaFile, 0);  

 with MFCanvas do  

 begin  

 {Draw the BMP into canvas}  

 Draw(0, 0, BMP);  

 {Free the Canvas}  

 Free;  

 end;  

 {Free the BMP}  

 BMP.Free;  

 with MetaFile do  

 begin  

 {Save the Metafile}  

 SaveToFile(WmfFile);  

  {Free it...}  

 Free;  

 end;  

end;