知道了原因,在 Delphi 7 中可以修改 DLL 代码如下:
library Project33;
uses
Windows,
SysUtils,
Classes,
Graphics;
{$R *.res}
procedure DrawIt(const bmp: TBitmap);
var
B:TBitmap;
begin
B:=TBitmap.Create;
try
B.Width:=bmp.Width;
B.Height:=bmp.Height;
BitBlt(B.Canvas.Handle, 0,0,B.Width,B.Height,bmp.Canvas.Handle,0,0,SRCCOPY);
B.Canvas.Pen.Color := clRed;
B.Canvas.Ellipse(10, 10, bmp.Width-10, bmp.Height-10);
BitBlt(bmp.Canvas.Handle, 0,0,B.Width,B.Height,B.Canvas.Handle,0,0,SRCCOPY);
finally
B.Free;
end;
end;
exports DrawIt;
begin
end.
这样修改后,调用就可以随意选择,可以使用 tseug,也可以使用我原来的方法:
(注意: tseug 原来声明的函数导出少了一点点东西 const)
procedure DrawIt(const bmp: TBitmap);external 'project33.dll';
procedure TForm1.EllipseToBitmap(bmp: TBitmap);
var
B:TBitmap;
begin
B:=TBitmap.Create;
try
B.Assign(bmp);
DrawIt(B);
bmp.Assign(B);
finally
B.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EllipseToBitmap(Image1.Picture.Bitmap);
end;