From: Dirk Lemstra Date: Sun, 7 May 2017 20:43:29 +0000 (+0200) Subject: Fixed incorrect page offset reported in #463 and #479. X-Git-Tag: 7.0.5-6~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d878a2036434a0b94c75ab2c8664ec6cf7c9e4db;p=imagemagick Fixed incorrect page offset reported in #463 and #479. --- diff --git a/coders/pdf.c b/coders/pdf.c index 228284023..55f32d6e7 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -1278,6 +1278,7 @@ RestoreMSCWarning ssize_t count, + page_count, y; struct tm @@ -1426,6 +1427,7 @@ RestoreMSCWarning (double) object+1); (void) WriteBlobString(image,buffer); count=(ssize_t) (pages_id+ObjectsPerImage+1); + page_count=1; if (image_info->adjoin != MagickFalse) { Image @@ -1437,6 +1439,10 @@ RestoreMSCWarning kid_image=image; for ( ; GetNextImageInList(kid_image) != (Image *) NULL; count+=ObjectsPerImage) { + page_count++; + profile=GetImageProfile(kid_image,"icc"); + if (profile != (StringInfo *) NULL) + count+=2; (void) FormatLocaleString(buffer,MagickPathExtent,"%.20g 0 R ",(double) count); (void) WriteBlobString(image,buffer); @@ -1449,13 +1455,18 @@ RestoreMSCWarning } (void) WriteBlobString(image,"]\n"); (void) FormatLocaleString(buffer,MagickPathExtent,"/Count %.20g\n",(double) - ((count-pages_id)/ObjectsPerImage)); + page_count); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,">>\n"); (void) WriteBlobString(image,"endobj\n"); scene=0; do { + MagickBooleanType + has_icc_profile; + + profile=GetImageProfile(image,"icc"); + has_icc_profile=(profile != (StringInfo *) NULL) ? MagickTrue : MagickFalse; compression=image->compression; if (image_info->compression != UndefinedCompression) compression=image_info->compression; @@ -1624,11 +1635,7 @@ RestoreMSCWarning (double) object+1); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MagickPathExtent,"/Thumb %.20g 0 R\n", - (double) object+8); - profile=GetImageProfile(image,"icc"); - if (profile != (StringInfo *) NULL) - (void) FormatLocaleString(buffer,MagickPathExtent,"/Thumb %.20g 0 R\n", - (double) object+10); + (double) object+(has_icc_profile != MagickFalse ? 10 : 8)); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,">>\n"); (void) WriteBlobString(image,"endobj\n"); @@ -1811,11 +1818,7 @@ RestoreMSCWarning if (image->alpha_trait != UndefinedPixelTrait) { (void) FormatLocaleString(buffer,MagickPathExtent,"/SMask %.20g 0 R\n", - (double) object+7); - profile=GetImageProfile(image,"icc"); - if (profile != (StringInfo *) NULL) - (void) FormatLocaleString(buffer,MagickPathExtent, - "/SMask %.20g 0 R\n",(double) object+9); + (double) object+(has_icc_profile != MagickFalse ? 9 : 7)); (void) WriteBlobString(image,buffer); } (void) FormatLocaleString(buffer,MagickPathExtent,"/Length %.20g 0 R\n", @@ -2330,11 +2333,7 @@ RestoreMSCWarning tile_image->rows); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MagickPathExtent,"/ColorSpace %.20g 0 R\n", - (double) object-1); - profile=GetImageProfile(image,"icc"); - if (profile != (StringInfo *) NULL) - (void) FormatLocaleString(buffer,MagickPathExtent, - "/ColorSpace %.20g 0 R\n",(double) object-3); + (double) object-(has_icc_profile != MagickFalse ? 3 : 1)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MagickPathExtent,"/BitsPerComponent %d\n", (compression == FaxCompression) || (compression == Group4Compression) ?