fpvectorial-eps: Fixes a bug in the tokenizer, arrays were not getting added to dictionaries

git-svn-id: trunk@42280 -
This commit is contained in:
sekelsenmat 2013-08-03 14:07:07 +00:00
parent 1d1b2f5395
commit e2aff28251
2 changed files with 30 additions and 1 deletions

View File

@ -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]);

View File

@ -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);