我正在尝试使用 GDI 绘制多边形。此代码有效:
type
TPolygon: Array[0..2] of TPoint;
var
ACanvas: TGPGraphics;
MyBrush: TGPLinearGradientBrush;
...
procedure DrawPolygon;
var
Polygon: TPolygon;
begin
Polygon[0].X := 1;
Polygon[0].Y := 5;
Polygon[1].X := 10;
Polygon[1].Y := 15;
Polygon[2].X := 1;
Polygon[2].Y := 5;
ACanvas.FillPolygon(MyBrush, PGPPoint(@Polygon), length(Polygon));
end;
...
此代码产生GDI 值溢出错误:
type
TPolygon: Array of TPoint;
var
ACanvas: TGPGraphics;
MyBrush: TGPLinearGradientBrush;
...
procedure DrawPolygon;
var
Polygon: TPolygon;
begin
SetLength(Polygon, 3);
Polygon[0].X := 1;
Polygon[0].Y := 5;
Polygon[1].X := 10;
Polygon[1].Y := 15;
Polygon[2].X := 1;
Polygon[2].Y := 5;
ACanvas.FillPolygon(MyBrush, PGPPoint(@Polygon), length(Polygon));
end;
...
唯一的区别是一个点数组是动态的,另一个是静态的。显然底层的内存值是不同的,但是以什么方式呢?