mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-18 21:39:23 +02:00
fpvectorial: Automatically close polygon read from wmf; introduce BkMode in wmf reader/writer.
git-svn-id: trunk@52825 -
This commit is contained in:
parent
fb89d63113
commit
9b89d6e007
@ -79,6 +79,8 @@ function GetLinePolygonIntersectionPoints(ACoord: Double;
|
||||
const APoints: T2DPointsArray; ACoordIsX: Boolean): T2DPointsArray; overload;
|
||||
function Rotate2DPoint(P, RotCenter: TPoint; alpha:double): TPoint;
|
||||
function Rotate3DPointInXY(P, RotCenter: T3DPoint; alpha:double): T3DPoint;
|
||||
function SamePoint(P1, P2: T3DPoint; Epsilon: Double = 0.0): Boolean; overload;
|
||||
function SamePoint(P1, P2: TPoint): Boolean; overload;
|
||||
procedure NormalizeRect(var ARect: TRect);
|
||||
// Transformation matrix operations
|
||||
// See http://www.useragentman.com/blog/2011/01/07/css3-matrix-transform-for-the-mathematically-challenged/
|
||||
@ -847,6 +849,18 @@ begin
|
||||
result.z := P.z;
|
||||
end;
|
||||
|
||||
function SamePoint(P1, P2: TPoint): Boolean;
|
||||
begin
|
||||
Result := (P1.X = P2.X) and (P1.Y = P2.Y);
|
||||
end;
|
||||
|
||||
function SamePoint(P1, P2: T3DPoint; Epsilon: Double = 0.0): Boolean;
|
||||
begin
|
||||
Result := SameValue(P1.X, P2.X, Epsilon) and
|
||||
SameValue(P1.Y, P2.Y, Epsilon) and
|
||||
SameValue(P1.Z, P2.Z, Epsilon);
|
||||
end;
|
||||
|
||||
procedure NormalizeRect(var ARect: TRect);
|
||||
var
|
||||
tmp: Integer;
|
||||
|
@ -397,9 +397,9 @@ const
|
||||
MEMORYMETAFILE = $0001; // Metafile is stored in memory
|
||||
DISKMETAFILE = $0002; // ... on disk.
|
||||
|
||||
// MixMode
|
||||
TRANSPARENT = $0001;
|
||||
OPAQUE = $0002;
|
||||
// Background MixMode for text, hatched brushes and other nonsolid pen styles
|
||||
BM_TRANSPARENT = $0001;
|
||||
BM_OPAQUE = $0002;
|
||||
|
||||
// Pen styles
|
||||
PS_COSMETIC = $0000;
|
||||
|
@ -52,6 +52,7 @@ type
|
||||
FCurrPalette: TFPPalette;
|
||||
FCurrTextColor: TFPColor;
|
||||
FCurrTextAlign: Word;
|
||||
FCurrBkMode: Word;
|
||||
FCurrPolyFillMode: Word;
|
||||
FCurrRawFontHeight: Integer;
|
||||
FMapMode: Word;
|
||||
@ -74,6 +75,7 @@ type
|
||||
procedure DeleteObj(const AParams: TParamArray);
|
||||
procedure ReadArc(APage: TvVectorialpage; const AParams: TParamArray);
|
||||
procedure ReadBkColor(APage: TvVectorialPage; const AParams: TParamArray);
|
||||
procedure ReadBkMode(APage: TvVectorialPage; const AValue: Word);
|
||||
procedure ReadChord(APage: TvVectorialpage; const AParams: TParamArray);
|
||||
function ReadColor(const AParams: TParamArray; AIndex: Integer): TFPColor;
|
||||
procedure ReadExtTextOut(APage: TvVectorialPage; const AParams: TParamArray);
|
||||
@ -425,6 +427,12 @@ begin
|
||||
APage.BackgroundColor := ReadColor(AParams, 0);
|
||||
end;
|
||||
|
||||
procedure TvWMFVectorialReader.ReadBkMode(APage: TvVectorialPage;
|
||||
const AValue: Word);
|
||||
begin
|
||||
FCurrBkMode := AValue;
|
||||
end;
|
||||
|
||||
procedure TvWMFVectorialReader.ReadChord(APage: TvVectorialPage;
|
||||
const AParams: TParamArray);
|
||||
var
|
||||
@ -652,6 +660,8 @@ end;
|
||||
etc }
|
||||
procedure TvWMFVectorialReader.ReadPolygon(APage: TvVectorialPage;
|
||||
const AParams: TParamArray; AFilled: boolean);
|
||||
const
|
||||
EPS = 1E-6;
|
||||
var
|
||||
n: Integer;
|
||||
i, j: Integer;
|
||||
@ -665,6 +675,11 @@ begin
|
||||
pts[i] := Make3DPoint(ScaleX(SmallInt(AParams[j])), ScaleY(SmallInt(AParams[j+1])));
|
||||
inc(j, 2);
|
||||
end;
|
||||
// Automatically close polygon
|
||||
if not SamePoint(pts[0], pts[n-1], EPS) then begin
|
||||
SetLength(pts, n+1);
|
||||
pts[n] := pts[0];
|
||||
end;
|
||||
|
||||
poly := TvPolygon.Create(APage);
|
||||
poly.Points := pts;
|
||||
|
@ -77,6 +77,7 @@ type
|
||||
procedure UpdateBounds(x, y: Integer);
|
||||
|
||||
procedure WriteBkColor(AStream: TStream; APage: TvVectorialPage);
|
||||
procedure WriteBkMode(AStream: TStream; AMode: Word);
|
||||
procedure WriteBrush(AStream: TStream; ABrush: TvBrush);
|
||||
procedure WriteEllipse(AStream: TStream; AEllipse: TvEllipse);
|
||||
procedure WriteEOF(AStream: TStream);
|
||||
@ -382,6 +383,12 @@ begin
|
||||
WriteWMFRecord(AStream, META_SETBKCOLOR, rec, SizeOf(rec));
|
||||
end;
|
||||
|
||||
procedure TvWMFVectorialWriter.WriteBkMode(AStream: TStream; AMode: Word);
|
||||
begin
|
||||
if AMode in [BM_TRANSPARENT, BM_OPAQUE] then
|
||||
WriteWMFRecord(AStream, META_SETBKMODE, AMode);
|
||||
end;
|
||||
|
||||
procedure TvWMFVectorialWriter.WriteBrush(AStream: TStream; ABrush: TvBrush);
|
||||
var
|
||||
rec: TWMFBrushRecord;
|
||||
@ -582,6 +589,7 @@ begin
|
||||
WriteWindowOrg(AStream);
|
||||
WriteMapMode(AStream);
|
||||
WriteBkColor(AStream, APage);
|
||||
WriteBkMode(AStream, BM_TRANSPARENT);
|
||||
WriteTextAlign(AStream, TA_BASELINE or TA_LEFT);
|
||||
|
||||
WritePageEntities(AStream, APage);
|
||||
|
Loading…
Reference in New Issue
Block a user