mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 01:48:03 +02:00
fpvectorial: Improvements in visualtests, wmf format.
This commit is contained in:
parent
9b0f2fd0fd
commit
f27a9ad86f
@ -12,7 +12,7 @@ interface
|
||||
|
||||
uses lazlogger,
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
ExtCtrls, ComCtrls, EditBtn, Buttons, fpimage, fpvectorial, Types;
|
||||
ExtCtrls, ComCtrls, Buttons, fpimage, fpvectorial, Types;
|
||||
|
||||
type
|
||||
|
||||
@ -102,7 +102,6 @@ type
|
||||
procedure Populate;
|
||||
procedure PrepareDoc(var ADoc: TvVectorialDocument; var APage: TvVectorialPage;
|
||||
AUseTopLeftCoords: boolean);
|
||||
procedure ReadIni;
|
||||
procedure ShowFileImage(AFilename: String; AUseTopLeftCoords: Boolean;
|
||||
APaintbox: TPaintbox);
|
||||
procedure ShowRefImageTest;
|
||||
@ -111,8 +110,11 @@ type
|
||||
procedure UpdateCmdStates;
|
||||
procedure UpdateResultStates;
|
||||
procedure UpdateTestResults;
|
||||
|
||||
procedure ReadIni;
|
||||
procedure WriteIni;
|
||||
|
||||
private
|
||||
// Simple shapes, solid fills and gradients
|
||||
procedure Render_Shape(APage: TvVectorialPage; AIntParam: Integer);
|
||||
|
||||
@ -154,6 +156,7 @@ const
|
||||
IMG_FOLDER = 'images' + PathDelim;
|
||||
REFIMG_FOLDER = IMG_FOLDER + 'ref' + PathDelim;
|
||||
NOT_SAVED = '(not saved)';
|
||||
FORMAT_SEPARATOR = ';';
|
||||
|
||||
function RenderStateToStr(AState: TRenderState): String;
|
||||
begin
|
||||
@ -166,11 +169,17 @@ var
|
||||
n: Integer;
|
||||
p: Integer;
|
||||
begin
|
||||
Result := rsUnknown;
|
||||
|
||||
p := pos(':', s);
|
||||
if p > 0 then
|
||||
s := Copy(s, p+1);
|
||||
if s = '' then
|
||||
exit;
|
||||
|
||||
n := GetEnumValue(TypeInfo(TRenderState), 'rs' + s);
|
||||
Result := TRenderState(n);
|
||||
if n in [0..2] then
|
||||
Result := TRenderState(n);
|
||||
end;
|
||||
|
||||
|
||||
@ -952,18 +961,26 @@ begin
|
||||
try
|
||||
ini.ReadSection('Results', List);
|
||||
for i := 0 to List.Count-1 do begin
|
||||
s := List[i];
|
||||
s := ini.ReadString('Results', List[i], '');
|
||||
node := Tree.Items.FindNodeWithTextPath(List[i]);
|
||||
if (s = '') or (node = nil) or (node.Data = nil) then
|
||||
Continue;
|
||||
sa := s.Split(';');
|
||||
sa := s.Split(FORMAT_SEPARATOR);
|
||||
TRenderParams(node.Data).RenderState[0] := StrToRenderState(sa[0]);
|
||||
//TRenderParams(node.Data).RenderState[1] := StrToRenderState(sa[1]);
|
||||
TRenderParams(node.Data).RenderState[1] := StrToRenderState(sa[1]);
|
||||
end;
|
||||
finally
|
||||
List.Free;
|
||||
end;
|
||||
|
||||
s := ini.ReadString('MainForm', 'FileFormat', '');
|
||||
if s <> '' then
|
||||
begin
|
||||
i := CbFileFormat.Items.IndexOf(s);
|
||||
if i <> -1 then
|
||||
CbFileFormat.ItemIndex := i;
|
||||
end;
|
||||
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
@ -980,12 +997,12 @@ var
|
||||
begin
|
||||
if ANode = nil then
|
||||
exit;
|
||||
renderParams := TRenderParams(ANode.Data);
|
||||
if Assigned(renderParams) then
|
||||
if (ANode.Data <> nil) then
|
||||
begin
|
||||
renderParams := TRenderParams(ANode.Data);
|
||||
if (renderParams.RenderState[0] <> rsUnknown) or (renderParams.RenderState[1] <> rsUnknown) then
|
||||
begin
|
||||
s := 'svg:' + RenderStateToStr(renderParams.RenderState[0]) + ';' +
|
||||
s := 'svg:' + RenderStateToStr(renderParams.RenderState[0]) + FORMAT_SEPARATOR +
|
||||
'wmf:' + RenderStateToStr(renderParams.RenderState[1]);
|
||||
ini.WriteString('Results', ANode.GetTextPath, s);
|
||||
end;
|
||||
@ -1006,6 +1023,8 @@ begin
|
||||
ini.WriteInteger('MainForm', 'Height', Height);
|
||||
end;
|
||||
|
||||
ini.WriteString('MainForm', 'FileFormat', cbFileFormat.Items[cbFileFormat.ItemIndex]);
|
||||
|
||||
ini.EraseSection('Results');
|
||||
WriteTestState(Tree.Items.GetFirstNode);
|
||||
|
||||
|
@ -317,7 +317,8 @@ const
|
||||
RADIUS = 40;
|
||||
begin
|
||||
if APage.UseTopLeftCoordinates then
|
||||
Result := CreateCircle(APage, CENTER_X, PAGE_SIZE - CENTER_Y, RADIUS) else
|
||||
Result := CreateCircle(APage, CENTER_X, PAGE_SIZE - CENTER_Y, RADIUS)
|
||||
else
|
||||
Result := CreateCircle(APage, CENTER_X, CENTER_Y, RADIUS);
|
||||
Result.Pen := StdPen(colBlack, 4);
|
||||
end;
|
||||
|
@ -628,12 +628,16 @@ var
|
||||
buf: array[0..80] of byte;
|
||||
placeableMetaHdr: TPlaceableMetaHeader absolute buf;
|
||||
wmfHdr: TWMFHeader absolute buf;
|
||||
n: Integer;
|
||||
begin
|
||||
AStream.Position := 0;
|
||||
|
||||
// Test if file begins with a placeable meta file header
|
||||
FHasPlaceableMetaHeader := false;
|
||||
AStream.ReadBuffer(buf{%H-}, SizeOf(TPlaceableMetaHeader));
|
||||
n := AStream.Read(buf{%H-}, SizeOf(TPlaceableMetaHeader));
|
||||
if n <> SizeOf(TPlaceableMetaHeader) then
|
||||
raise Exception.Create('Error reading the wmf file header.');
|
||||
|
||||
if placeableMetaHdr.Key = WMF_MAGIC_NUMBER then begin // yes!
|
||||
FHasPlaceableMetaHeader := true;
|
||||
FBBox.Left := placeableMetaHdr.Left;
|
||||
@ -812,6 +816,7 @@ var
|
||||
params: TParamArray = nil;
|
||||
page: TvVectorialPage;
|
||||
prevX, prevY: Word;
|
||||
n: Integer;
|
||||
begin
|
||||
page := AData.AddPage(not (vrf_UseBottomLeftCoords in Settings.VecReaderFlags));
|
||||
page.BackgroundColor := colWhite;
|
||||
@ -821,7 +826,9 @@ begin
|
||||
FRecordStartPos := AStream.Position;
|
||||
|
||||
// Read record size and function code
|
||||
AStream.ReadBuffer(wmfRec{%H-}, SizeOf(TWMFRecord));
|
||||
n := AStream.Read(wmfRec{%H-}, SizeOf(TWMFRecord));
|
||||
if n <> SizeOf(TWMFRecord) then
|
||||
raise Exception.Create('Record size error.');
|
||||
|
||||
{$IFDEF WMF_DEBUG}
|
||||
writeLn(Format('Record position: %0:d / Record size: %1:d words / Record type: %2:d ($%2:x): %3:s',
|
||||
@ -839,7 +846,7 @@ begin
|
||||
end;
|
||||
|
||||
// Read parameters
|
||||
SetLength(params{%H-}, wmfRec.Size - 3);
|
||||
SetLength(params, wmfRec.Size - 3);
|
||||
AStream.ReadBuffer(params[0], (wmfRec.Size - 3)*SIZE_OF_WORD);
|
||||
|
||||
// Process record, depending on function code
|
||||
@ -1046,8 +1053,8 @@ end;
|
||||
function TvWMFVectorialReader.ReadImage(const AParams: TParamArray;
|
||||
AIndex: Integer; AImage: TFPCustomImage): Boolean;
|
||||
var
|
||||
{%H-}bmpCoreHdr: PWMFBitmapCoreHeader;
|
||||
bmpInfoHdr: PWMFBitmapInfoHeader;
|
||||
bmpCoreHdr: PWMFBitmapCoreHeader = nil;
|
||||
bmpInfoHdr: PWMFBitmapInfoHeader = nil;
|
||||
hasCoreHdr: Boolean;
|
||||
bmpFileHdr: TBitmapFileHeader;
|
||||
w, h: Integer;
|
||||
|
@ -53,8 +53,8 @@ type
|
||||
FObjList: TWMFObjList;
|
||||
//
|
||||
FBBox: TRect; // in metafile units as specified by UnitsPerInch. NOTE: "logical" units can be different!
|
||||
FLogicalMaxX: Word; // Max x coordinate used for scaling
|
||||
FLogicalMaxY: Word; // Max y coordinate used for scaling
|
||||
FLogicalMaxX: Word; // Max x coordinate used for scaling, in logical units
|
||||
FLogicalMaxY: Word; // Max y coordinate used for scaling, in logical units
|
||||
FLogicalBounds: TRect; // Enclosing boundary rectangle in logical units
|
||||
FScalingFactor: Double; // Conversion fpvectorial units to logical units
|
||||
FMaxRecordSize: Int64;
|
||||
@ -65,7 +65,7 @@ type
|
||||
FCurrTextAnchor: TvTextAnchor;
|
||||
FCurrBkMode: Word;
|
||||
{%H-}FCurrPolyFillMode: Word;
|
||||
FUseTopLeftCoordinates: Boolean;
|
||||
FUseTopLeftCoordinates: Boolean; // If true, input coordinates are given in top/left coordinate system.
|
||||
FErrMsg: TStrings;
|
||||
|
||||
function CalcChecksum: Word;
|
||||
|
Loading…
Reference in New Issue
Block a user