:aimingoo, 时间:1998-9-10 8:42:59, ID:1636
下面的内容回答houyg的提问:
{File Convert[BMP&WMF/EMF] Tool Ver1.0, Full source by aiming.
===============================================================
请用命令行dcc -cc bmp2wmf.dpr编译,或设置"生成控制台程序"编译项
在IDE中编译。生成的程序只能在win95的DOS窗口中使用。
===============================================================}
program bmp2wmf;
uses
Graphics, SysUtils;
const SoftWareName = 'File Convert[BMP&WMF/EMF] Tool Ver1.0,';
CompanyName = 'copyright(c) 1994,98 Keenvim software';
Width = 80 - Length(SoftWareName);
var aBmp : Tbitmap;
aWmf : TMetaFile;
param1 : String;
paramExt : String;
begin
Write(SoftWareName,CompanyName:Width);
Writeln('By Mr. Aiming Zhou.'); Writeln;
if ParamCount >= 1 then
begin
param1 := UpperCase(ParamStr(1));
paramExt := ExtractFileExt(param1);
end;
if (ParamCount < 1) or
(ParamCount > 2) or
((ParamCount = 2) and (UpperCase(ParamStr(2)) <> '/E')) or
((paramExt <> '.BMP') and (paramExt <> '.WMF')
and (paramExt <> '.EMF')) then
begin
writeln('ERROR: Param Invalid!');
writeln('Usage: Bmp2Wmf <.Bmp/.Wmf> [/E]');
writeln('notes: Param [/E] Define ouput .EMF File format.');
exit;
end;
aBmp := Tbitmap.Create;
aWmf := TMetaFile.Create;
if paramExt = '.BMP'
then
begin
aBmp.LoadFromFile(param1);
aWmf.Width := aBmp.Width;
aWmf.Height := aBmp.Height;
if ParamCount = 2 then aWmf.Enhanced := true
else aWmf.Enhanced := false;
with TMetaFileCanvas.CreateWithComment(
aWmf,0,'Aiming''s Conver program','V1.0') do
Try Draw(0,0,aBmp);
Finally Free;
end;
if aWmf.Enhanced
then aWmf.SaveToFile(copy(param1,1,pos('.',param1)) + 'EMF')
else aWmf.SaveToFile(copy(param1,1,pos('.',param1)) + 'WMF');
if aWmf.Enhanced
then writeln(param1, '==>',
copy(param1,1,pos('.',param1)) + 'EMF', #$0D)
else writeln(param1, '==>',
copy(param1,1,pos('.',param1)) + 'WMF', #$0D);
end
else
begin
aWmf.LoadFromFile(param1);
aBmp.Width := aWmf.Width;
aBmp.Height := aWmf.Height;
aBmp.Canvas.Draw(0,0,aWmf);
aBmp.SaveToFile(copy(param1,1,pos('.',param1)) + 'BMP');
writeln(param1, '==>',
copy(param1,1,pos('.',param1)) + 'EMF', #$0D);
end;
aBmp.Destroy;
aWmf.Destroy;
end.