[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#632031: convert: gray colorspace creates broken postscript



On Wed, 29 Jun 2011 14:00:11 +0200
Bastien ROUCARIES <roucaries.bastien@gmail.com> wrote:

> Thanks bug both in imagemagick and in ghostscript ....
> 
> It seems that bounding box printing need a cast to int at least for
> the page. Need to read specs for other field.

In fact, casting isn't necessary at all, at least for the printing of
the image columns and rows. The corresponding variables (structure
elements) are of integer type already. So I'd like to suggest the
appended patch to conquer the problem. It eliminates the casts
and replaces '%.20g' with '%zd' in the format string for the printing
of the image columns and rows.

As the diff indicates, some numbers of the DSC comments BoundingBox,
Pages and Page are also printed with fractional parts. This might be a
similar problem.


Best regards,
Christoph
commit e46e89e087b0710ccf9e508378158083e94c4d31
Author: Stephan Springl <springl@bfw-online.de>
Date:   2011-06-29 14:01:17 +0200

    diff

diff --git a/coders/ps.c b/coders/ps.c
index c0f47c3..bc3740d 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -1716,8 +1716,8 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image)
     /*
       Output image data.
     */
-    (void) FormatMagickString(buffer,MaxTextExtent,"%.20g %.20g\n%g %g\n%g\n",
-      (double) geometry.x,(double) geometry.y,scale.x,scale.y,pointsize);
+    (void) FormatMagickString(buffer,MaxTextExtent,"%zd %zd\n%g %g\n%g\n",
+      geometry.x, geometry.y,scale.x,scale.y,pointsize);
     (void) WriteBlobString(image,buffer);
     labels=(char **) NULL;
     value=GetImageProperty(image,"label");
@@ -1750,8 +1750,7 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image)
               Dump image as grayscale.
             */
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%.20g %.20g\n1\n1\n1\n8\n",(double) image->columns,(double)
-              image->rows);
+              "%zd %zd\n1\n1\n1\n8\n", image->columns, image->rows);
             (void) WriteBlobString(image,buffer);
             q=pixels;
             for (y=0; y < (ssize_t) image->rows; y++)

Reply to: