BMP 转换为 WMF格式后,图像变大的问题(300分)

  • 主题发起人 主题发起人 tempc
  • 开始时间 开始时间
T

tempc

Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下代码将Bitmap转换为WMF格式后,发现WMF图像变大了,原来Bitmap只有300 * 45大小的,可是转换后的WMF却有354 * 53大小.请问是什么原因.

procedure BmpToWmf(BmpFile, WmfFile: string);
var
MetaFile: TMetaFile;
MFCanvas: TMetaFileCanvas;
BMP: TBitmap;
begin
MetaFile := TMetaFile.Create;
MetaFile.Enhanced := False; // Windows Meta File
try
BMP := TBitmap.Create;
try
BMP.LoadFromFile(BmpFile);
MetaFile.Height := BMP.Height;
MetaFile.Width := BMP.Width;
MFCanvas := TMetafileCanvas.Create(MetaFile, 0);
try
MFCanvas.Draw(0, 0, BMP);
finally
MFCanvas.Free;
end;
finally
BMP.Free;
end;
MetaFile.SaveToFile(WmfFile);
finally
MetaFile.Free;
end;
end;
 
procedure BmpToWmf (BmpFile,WmfFile:string);
var
MetaFile : TMetaFile;
MFCanvas : TMetaFileCanvas;
BMP : TBitmap;
begin
MetaFile := TMetaFile.Create;
BMP := TBitmap.create;
BMP.LoadFromFile(BmpFile);
MetaFile.Height := BMP.Height;
MetaFile.Width := BMP.Width;
MFCanvas:=TMetafileCanvas.Create(MetaFile, 0);
with MFCanvas do
begin
Draw(0, 0, BMP);
Free;
end;
BMP.Free;
with MetaFile do
begin
SaveToFile(WmfFile);
Free;
end;
end;

对比一下,好像多了句:MetaFile.Enhanced := False; // Windows Meta File
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

╰=========================================╯
 
后退
顶部