From 688f07b92c207046de0cdfb2235becdea77ef9e3 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 27 Sep 2009 15:19:13 +0000 Subject: [PATCH] --- coders/pcl.c | 10 +++++++++- magick/cache.c | 19 ++++++------------- magick/resource.c | 7 +------ magick/utility.c | 37 +++++++++++++++++++++++++++++++++++++ magick/utility.h | 3 +++ 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/coders/pcl.c b/coders/pcl.c index 22b5b6298..ab0ef2329 100644 --- a/coders/pcl.c +++ b/coders/pcl.c @@ -650,6 +650,9 @@ static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image) char buffer[MaxTextExtent]; + const char + *option; + long y; @@ -782,7 +785,12 @@ static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image) (void) WriteBlobString(image,buffer); } } - (void) WriteBlobString(image,"\033*r1A"); /* start raster graphics */ + option=GetImageOption(image_info,"pcl:fit-to-page"); + if ((option != (const char *) NULL) && + (IsMagickTrue(option) != MagickFalse)) + (void) WriteBlobString(image,"\033*r3A"); + else + (void) WriteBlobString(image,"\033*r1A"); /* start raster graphics */ (void) WriteBlobString(image,"\033*b0Y"); /* set y offset */ length=(image->columns*bits_per_pixel+7)/8; pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels)); diff --git a/magick/cache.c b/magick/cache.c index 30ca4dc44..ac19da1eb 100644 --- a/magick/cache.c +++ b/magick/cache.c @@ -4122,7 +4122,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, clone_image; long - pagesize; + page_size; MagickBooleanType status; @@ -4134,14 +4134,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, assert(image->cache != (void *) NULL); assert(filename != (const char *) NULL); assert(offset != (MagickOffsetType *) NULL); - pagesize=(-1); -#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PAGESIZE) - pagesize=sysconf(_SC_PAGESIZE); -#elif defined(MAGICKCORE_HAVE_GETPAGESIZE) && defined(MAGICKCORE_POSIX_SUPPORT) - pagesize=getpagesize(); -#endif - if (pagesize <= 0) - pagesize=4096; + page_size=GetMagickPageSize(); cache_info=(CacheInfo *) image->cache; assert(cache_info->signature == MagickSignature); if (attach != MagickFalse) @@ -4158,7 +4151,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, cache_info->offset=(*offset); if (OpenPixelCache(image,ReadMode,exception) == MagickFalse) return(MagickFalse); - *offset+=cache_info->length+pagesize-(cache_info->length % pagesize); + *offset+=cache_info->length+page_size-(cache_info->length % page_size); return(MagickTrue); } if ((cache_info->mode != ReadMode) && (cache_info->type != MemoryCache) && @@ -4179,8 +4172,8 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, { (void) CopyMagickString(cache_info->cache_filename,filename, MaxTextExtent); - *offset+=cache_info->length+pagesize-(cache_info->length % - pagesize); + *offset+=cache_info->length+page_size-(cache_info->length % + page_size); (void) UnlockSemaphoreInfo(cache_info->semaphore); cache_info=(CacheInfo *) ReferencePixelCache(cache_info); if (image->debug != MagickFalse) @@ -4209,7 +4202,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, if (status != MagickFalse) status=ClonePixelCachePixels(cache_info,clone_info,&image->exception); } - *offset+=cache_info->length+pagesize-(cache_info->length % pagesize); + *offset+=cache_info->length+page_size-(cache_info->length % page_size); clone_info=(CacheInfo *) DestroyPixelCache(clone_info); return(status); } diff --git a/magick/resource.c b/magick/resource.c index 6ca29d855..968691731 100644 --- a/magick/resource.c +++ b/magick/resource.c @@ -707,12 +707,7 @@ MagickExport void InitializeMagickResources(void) /* Set Magick resource limits. */ - pagesize=(-1); -#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PAGESIZE) - pagesize=sysconf(_SC_PAGESIZE); -#elif defined(MAGICKCORE_HAVE_GETPAGESIZE) && defined(MAGICKCORE_POSIX_SUPPORT) - pagesize=getpagesize(); -#endif + pagesize=GetMagickPageSize(); pages=(-1); #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) pages=sysconf(_SC_PHYS_PAGES); diff --git a/magick/utility.c b/magick/utility.c index 84ffd97c2..9cb59b43d 100644 --- a/magick/utility.c +++ b/magick/utility.c @@ -970,6 +970,43 @@ MagickExport MagickBooleanType GetExecutionPath(char *path,const size_t extent) % % % % % % +% G e t M a g i c k P a g e S i z e % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% GetMagickPageSize() returns the memory page size. +% +% The format of the GetMagickPageSize method is: +% +% long GetMagickPageSize() +% +*/ +MagickExport long GetMagickPageSize(void) +{ + static long + page_size = -1; + + if (page_size > 0) + return(page_size); +#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) + page_size=sysconf(_SC_PAGE_SIZE); +#endif +#if defined(MAGICKCORE_HAVE_GETPAGESIZE) + if (page_size <= 0) + page_size=getpagesize(); +#endif + if (page_size <= 0) + page_size=16384; + return(page_size); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % G e t P a t h A t t r i b u t e s % % % % % diff --git a/magick/utility.h b/magick/utility.h index 0ba2e6f2e..d650ae16c 100644 --- a/magick/utility.h +++ b/magick/utility.h @@ -46,6 +46,9 @@ extern MagickExport FILE extern MagickExport int SystemCommand(const MagickBooleanType,const char *,ExceptionInfo *); +extern MagickExport long + GetMagickPageSize(void); + extern MagickExport MagickBooleanType AcquireUniqueFilename(char *), AcquireUniqueSymbolicLink(const char *,char *), -- 2.40.0