BMP<-->WMF/EMF

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
:aimingoo, 时间:1998-9-10 8:42:59, ID:1636
下面的内容回答houyg的提问:
{File Convert[BMP&amp;WMF/EMF] Tool Ver1.0, Full source by aiming.
===============================================================
请用命令行dcc -cc bmp2wmf.dpr编译,或设置&quot;生成控制台程序&quot;编译项
在IDE中编译。生成的程序只能在win95的DOS窗口中使用。
===============================================================}
program bmp2wmf;
uses
Graphics, SysUtils;
const SoftWareName = 'File Convert[BMP&amp;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 &gt;= 1 then
begin
param1 := UpperCase(ParamStr(1));
paramExt := ExtractFileExt(param1);
end;
if (ParamCount &lt; 1) or
(ParamCount &gt; 2) or
((ParamCount = 2) and (UpperCase(ParamStr(2)) &lt;&gt; '/E')) or
((paramExt &lt;&gt; '.BMP') and (paramExt &lt;&gt; '.WMF')
and (paramExt &lt;&gt; '.EMF')) then
begin
writeln('ERROR: Param Invalid!');
writeln('Usage: Bmp2Wmf &lt;.Bmp/.Wmf&gt; [/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, '==&gt;',
copy(param1,1,pos('.',param1)) + 'EMF', #$0D)
else writeln(param1, '==&gt;',
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, '==&gt;',
copy(param1,1,pos('.',param1)) + 'EMF', #$0D);
end;
aBmp.Destroy;
aWmf.Destroy;
end.
 
 
 

Similar threads

后退
顶部