你可以考虑自定义组件TShape,
重载 Paint ,然后在自己把 Canvas 复制到bitmap中备份起来。
然后输出一个方法从 bitmap中取点,就可以了。
或者 在输出的方法中重新画一次到一个临时的 bitmap 中,再取点,这样更节约内存。
unit shape1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Graphics;
type
tshape1 = class(tshape)
private
FBmp: TBitmap;
{ Private declarations }
protected
{ Protected declarations }
procedure Paint; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
function getpixcolor(x, y: integer): tcolor;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [tshape1]);
end;
{ tshape1 }
constructor tshape1.Create(AOwner: TComponent);
begin
FBmp := TBitmap.Create;
inherited;
end;
destructor tshape1.Destroy;
begin
FBmp.Free;
inherited;
end;
function tshape1.getpixcolor(x, y: integer): tcolor;
begin
result := fbmp.Canvas.Pixels[x, y];
end;
procedure tshape1.Paint;
begin
inherited;
FBmp.Width := Width;
FBmp.Height := Height;
FBmp.Canvas.CopyRect(ClientRect, Canvas, ClientRect);
end;
end.