From e2aff282510483c9331202d91cec9664e66be5b2 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sat, 3 Aug 2013 14:07:07 +0000 Subject: [PATCH] fpvectorial-eps: Fixes a bug in the tokenizer, arrays were not getting added to dictionaries git-svn-id: trunk@42280 - --- components/fpvectorial/epsvectorialreader.pas | 23 ++++++++++++++++++- components/fpvectorial/fpvutils.pas | 8 +++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/components/fpvectorial/epsvectorialreader.pas b/components/fpvectorial/epsvectorialreader.pas index c7b27f4724..658008359b 100644 --- a/components/fpvectorial/epsvectorialreader.pas +++ b/components/fpvectorial/epsvectorialreader.pas @@ -23,6 +23,7 @@ unit epsvectorialreader; {.$define FPVECTORIALDEBUG_CONTROL} {.$define FPVECTORIALDEBUG_ARITHMETIC} {.$define FPVECTORIALDEBUG_CLIP_REGION} +{$define FPVECTORIAL_IMAGE_DICTIONARY_DEBUG} interface @@ -129,6 +130,8 @@ type OverPrint: Boolean; // not used currently ColorSpaceName: string; // Current Transformation Matrix + // + // See http://www.useragentman.com/blog/2011/01/07/css3-matrix-transform-for-the-mathematically-challenged/ // This has 6 numbers, which means this: // (a c e) // [a, b, c, d, e, f] = (b d f) @@ -636,8 +639,15 @@ begin ArrayToken.ResolveOperators(); if ArrayToken.Parent = nil then begin - Tokens.Add(ArrayToken); State := TPostScriptScannerState(lReturnState.Pop()); + if State = ssInDictionary then + begin + DictionaryToken.Childs.Add(ArrayToken); + end + else + begin + Tokens.Add(ArrayToken); + end; end else begin @@ -1776,7 +1786,9 @@ begin if TExpressionToken(ANextToken).ETType <> ettRawData then raise Exception.Create('[TvEPSVectorialReader.ExecutePaintingOperator] operator image: Image contents is not a raw data.'); lImageDataStr := TExpressionToken(ANextToken).StrValue; SetLength(lImageDataStr, Length(lImageDataStr)-2); // Remove the final ~> + {$ifdef FPVECTORIAL_DEFLATE_DEBUG} FPVUDebugLn('[image] ImageDataStr='+lImageDataStr); + {$endif} lFindIndex := TDictionaryToken(Param1).Names.IndexOf('ASCII85Decode'); if lFindIndex > 0 then @@ -1800,6 +1812,15 @@ begin lImageBitsPerComponent := 0; lImageMatrix := nil; lFindIndex := TDictionaryToken(Param1).Names.IndexOf('ImageType'); + // debug dump all dictionary names + {$ifdef FPVECTORIAL_IMAGE_DICTIONARY_DEBUG} + FPVUDebug('TDictionaryToken(Param1).Names='); + for i := 0 to TDictionaryToken(Param1).Names.Count-1 do + begin + FPVUDebug(TDictionaryToken(Param1).Names.Strings[i]+' '); + end; + FPVUDebugLn(''); + {$endif} if lFindIndex > 0 then begin lCurDictToken := TPSToken(TDictionaryToken(Param1).Values[lFindIndex]); diff --git a/components/fpvectorial/fpvutils.pas b/components/fpvectorial/fpvutils.pas index 6093eb1693..9c649796b5 100644 --- a/components/fpvectorial/fpvutils.pas +++ b/components/fpvectorial/fpvutils.pas @@ -13,6 +13,7 @@ unit fpvutils; {$define USE_LCL_CANVAS} {.$define FPVECTORIAL_BEZIERTOPOINTS_DEBUG} +{.$define FPVECTORIAL_DEFLATE_DEBUG} {$ifdef fpc} {$mode delphi} @@ -55,6 +56,7 @@ procedure ConvertPathToPoints(APath: TPath; ADestX, ADestY: Integer; AMulX, AMul function Rotate2DPoint(P, RotCenter: TPoint; alpha:double): TPoint; function Rotate3DPointInXY(P, RotCenter: T3DPoint; alpha:double): T3DPoint; // Transformation matrix operations +// See http://www.useragentman.com/blog/2011/01/07/css3-matrix-transform-for-the-mathematically-challenged/ procedure ConvertTransformationMatrixToOperations(AA, AB, AC, AD, AE, AF: Double; out ATranslateX, ATranslateY, AScaleX, AScaleY, ASkewX, ASkewY, ARotate: Double); procedure InvertMatrixOperations(var ATranslateX, ATranslateY, AScaleX, AScaleY, ASkewX, ASkewY, ARotate: Double); // Numerical Calculus @@ -448,13 +450,19 @@ begin DestMem := TMemoryStream.Create; try // copy the source to the stream + {$ifdef FPVECTORIAL_DEFLATE_DEBUG} FPVUDebug('[DeflateBytes] ASource= '); + {$endif} for i := 0 to Length(ASource)-1 do begin SourceMem.WriteByte(ASource[i]); + {$ifdef FPVECTORIAL_DEFLATE_DEBUG} FPVUDebug(Format('%.2x ', [ASource[i]])); + {$endif} end; + {$ifdef FPVECTORIAL_DEFLATE_DEBUG} FPVUDebugLn(''); + {$endif} SourceMem.Position := 0; DeflateStream(SourceMem, DestMem);