fpvectorial: Automatically close subpolygons of a polypolygon read from wmf. Don't close polylines.

git-svn-id: trunk@52826 -
This commit is contained in:
wp 2016-08-18 05:45:38 +00:00
parent 9b89d6e007
commit efd1f9eca5

View File

@ -675,8 +675,8 @@ begin
pts[i] := Make3DPoint(ScaleX(SmallInt(AParams[j])), ScaleY(SmallInt(AParams[j+1]))); pts[i] := Make3DPoint(ScaleX(SmallInt(AParams[j])), ScaleY(SmallInt(AParams[j+1])));
inc(j, 2); inc(j, 2);
end; end;
// Automatically close polygon // Automatically close polygon (but not polyline)
if not SamePoint(pts[0], pts[n-1], EPS) then begin if AFilled and not SamePoint(pts[0], pts[n-1], EPS) then begin
SetLength(pts, n+1); SetLength(pts, n+1);
pts[n] := pts[0]; pts[n] := pts[0];
end; end;
@ -700,6 +700,8 @@ end;
procedure TvWMFVectorialReader.ReadPolyPolygon(APage: TvVectorialPage; procedure TvWMFVectorialReader.ReadPolyPolygon(APage: TvVectorialPage;
const AParams: TParamArray); const AParams: TParamArray);
const
EPS = 1E-6;
var var
nPoly: Integer; nPoly: Integer;
nPts: array of Integer; nPts: array of Integer;
@ -707,6 +709,7 @@ var
i, j, k: Integer; i, j, k: Integer;
path: TPath; path: TPath;
P: T3DPoint; P: T3DPoint;
Pstart: T3DPoint;
begin begin
k := 0; k := 0;
nPoly := AParams[k]; nPoly := AParams[k];
@ -719,14 +722,17 @@ begin
APage.StartPath; APage.StartPath;
for j := 0 to nPoly-1 do begin for j := 0 to nPoly-1 do begin
P := Make3DPoint(ScaleX(SmallInt(AParams[k])), ScaleY(SmallInt(AParams[k+1]))); PStart := Make3DPoint(ScaleX(SmallInt(AParams[k])), ScaleY(SmallInt(AParams[k+1])));
inc(k, 2); inc(k, 2);
APage.AddMoveToPath(P.X, P.Y); APage.AddMoveToPath(PStart.X, PStart.Y);
for i := 1 to nPts[j]-1 do begin for i := 1 to nPts[j]-1 do begin
P := Make3DPoint(ScaleX(SmallInt(AParams[k])), ScaleY(SmallInt(AParams[k+1]))); P := Make3DPoint(ScaleX(SmallInt(AParams[k])), ScaleY(SmallInt(AParams[k+1])));
inc(k, 2); inc(k, 2);
APage.AddLineToPath(P.X, P.Y); APage.AddLineToPath(P.X, P.Y);
end; end;
// Close polygon
if not SamePoint(P, PStart, EPS) then
APage.AddLineToPath(PStart.X, PStart.Y);
end; end;
path := APage.EndPath; path := APage.EndPath;
path.Pen := FCurrPen; path.Pen := FCurrPen;