下面介绍了如何安装ImageMagickObject,并在Delphi中调用,下面的代码将一张图片修改尺寸后保存,调用还是比较简单的。
来自:http://www.haotu.net
需要将ImageMagickObject.DLL安装到activeX控件,方法如下:
1. Install ImageMagick - check ”Install ImageMagickObject”
2. Run Delphi, import ImageMagickObject type library (Delphi 7 - menu: ”Project”/”Import Type Library”)
- this should create unit ImageMagickObject_TLB.pas
安装ImageMagick需要安装:ImageMagick-6.5.1-0-Q16-windows-dll  包,安装时有个ole的选项要勾选,负责找不到ImageMagickObject。
// uses section for GUI application:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImageMagickObject_TLB, activeX, StdCtrls;
// Example procedure using COM object
procedure Test;
var
v : Variant;
im : TMagickImage;
begin
im := TMagickImage.Create(nil);
try
v := VarArrayCreate([0, 3], varVariant);
v[0] := 'logo:';
// rotation example
// v[1] := '-rotate';
// v[2] := '10';
// crop example - crop to 94x103 starting at 30, 25
// v[1] := '-crop';
// v[2] := '94x103+30+25';
// resize example - set width = 150 (will keep aspect ratio)
v[1] := '-resize';
v[2] := '150';
// output filename
v[3] := 'logo2.jpg';
// execution
im.Convert(PSafeArray(TVarData(v).VArray));
finally
im.Free;
end;
end;
