From 6cde06a84ca01328d0e4744a41b5e71957b79684 Mon Sep 17 00:00:00 2001 From: cristy Date: Thu, 24 Nov 2011 00:08:43 +0000 Subject: [PATCH] --- coders/ps.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/coders/ps.c b/coders/ps.c index 988bc1ace..cc75b91de 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -477,21 +477,35 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((flags & SigmaValue) == 0) image->resolution.y=image->resolution.x; } + if (image_info->density != (char *) NULL) + { + flags=ParseGeometry(image_info->density,&geometry_info); + image->resolution.x=geometry_info.rho; + image->resolution.y=geometry_info.sigma; + if ((flags & SigmaValue) == 0) + image->resolution.y=image->resolution.x; + } + (void) ParseAbsoluteGeometry(PSPageGeometry,&page); + if (image_info->page != (char *) NULL) + (void) ParseAbsoluteGeometry(image_info->page,&page); + page.width=(size_t) ceil((double) (page.width*image->resolution.x/delta.x)- + 0.5); + page.height=(size_t) ceil((double) (page.height*image->resolution.y/delta.y)- + 0.5); /* Determine page geometry from the Postscript bounding box. */ (void) ResetMagickMemory(&bounds,0,sizeof(bounds)); - (void) ResetMagickMemory(&hires_bounds,0,sizeof(hires_bounds)); - (void) ResetMagickMemory(&page,0,sizeof(page)); (void) ResetMagickMemory(command,0,sizeof(command)); + cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse; + (void) ResetMagickMemory(&hires_bounds,0,sizeof(hires_bounds)); priority=0; rows=0; extent=0; spotcolor=0; language_level=1; - skip=MagickFalse; - cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse; pages=(~0UL); + skip=MagickFalse; p=command; for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image)) { @@ -636,6 +650,8 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) value=DestroyString(value); continue; } + if (image_info->page != (char *) NULL) + continue; /* Note region defined by bounding box. */ @@ -685,8 +701,10 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) hires_bounds.x2-hires_bounds.x1,hires_bounds.y2-hires_bounds.y1, hires_bounds.x1,hires_bounds.y1); (void) SetImageProperty(image,"ps:HiResBoundingBox",geometry,exception); - page.width=(size_t) floor(hires_bounds.x2-hires_bounds.x1+0.5); - page.height=(size_t) floor(hires_bounds.y2-hires_bounds.y1+0.5); + page.width=(size_t) ceil((double) ((hires_bounds.x2-hires_bounds.x1)* + image->resolution.x/delta.x)-0.5); + page.height=(size_t) ceil((double) ((hires_bounds.y2-hires_bounds.y1)* + image->resolution.y/delta.y)-0.5); } (void) CloseBlob(image); if (IsRGBColorspace(image_info->colorspace) != MagickFalse) @@ -734,24 +752,8 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) return((Image *) NULL); } *options='\0'; - if ((page.width == 0) || (page.height == 0)) - (void) ParseAbsoluteGeometry(PSPageGeometry,&page); - if (image_info->density != (char *) NULL) - { - flags=ParseGeometry(image_info->density,&geometry_info); - image->resolution.x=geometry_info.rho; - image->resolution.y=geometry_info.sigma; - if ((flags & SigmaValue) == 0) - image->resolution.y=image->resolution.x; - } (void) FormatLocaleString(density,MaxTextExtent,"%gx%g", image->resolution.x,image->resolution.y); - if (image_info->page != (char *) NULL) - (void) ParseAbsoluteGeometry(image_info->page,&page); - page.width=(size_t) floor((double) (page.width*image->resolution.x/delta.x)+ - 0.5); - page.height=(size_t) floor((double) (page.height*image->resolution.y/delta.y)+ - 0.5); (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double) page.width,(double) page.height); read_info=CloneImageInfo(image_info); @@ -1861,7 +1863,7 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image, }; if (image->previous == (Image *) NULL) { - status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (status == MagickFalse) break; -- 2.40.0