X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=coders%2Fpdf.c;h=61535ba72488428cee3f045e47d15a2514b47c6c;hb=77b33baacfae08c3794dd19df1862fb645ebe265;hp=8166b5c9db32dbd1cab39fef33e28f5af141f1e5;hpb=aff6d807f839a998fff6e87198f2418868ab508e;p=imagemagick
diff --git a/coders/pdf.c b/coders/pdf.c
index 8166b5c9d..61535ba72 100644
--- a/coders/pdf.c
+++ b/coders/pdf.c
@@ -17,7 +17,7 @@
% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
@@ -39,40 +39,45 @@
/*
Include declarations.
*/
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/color.h"
-#include "magick/color-private.h"
-#include "magick/colorspace.h"
-#include "magick/compress.h"
-#include "magick/constitute.h"
-#include "magick/delegate.h"
-#include "magick/delegate-private.h"
-#include "magick/draw.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/geometry.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/option.h"
-#include "magick/profile.h"
-#include "magick/property.h"
-#include "magick/quantum-private.h"
-#include "magick/resource_.h"
-#include "magick/resize.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/transform.h"
-#include "magick/utility.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/compress.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/delegate.h"
+#include "MagickCore/delegate-private.h"
+#include "MagickCore/draw.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/geometry.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/option.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/profile.h"
+#include "MagickCore/property.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/resize.h"
+#include "MagickCore/signature.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/token.h"
+#include "MagickCore/transform.h"
+#include "MagickCore/utility.h"
+#include "MagickCore/module.h"
/*
Define declarations.
@@ -87,7 +92,7 @@
Forward declarations.
*/
static MagickBooleanType
- WritePDFImage(const ImageInfo *,Image *);
+ WritePDFImage(const ImageInfo *,Image *,ExceptionInfo *);
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -177,6 +182,8 @@ static MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose,
}
code=0;
argv=StringToArgv(command,&argc);
+ if (argv == (char **) NULL)
+ return(MagickFalse);
status=(ghost_info->init_with_args)(interpreter,argc-1,argv+1);
if (status == 0)
status=(ghost_info->run_string)(interpreter,"systemdict /start get exec\n",
@@ -289,7 +296,9 @@ static MagickBooleanType IsPDFRendered(const char *path)
static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
+#define CMYKProcessColor "CMYKProcessColor"
#define CropBox "CropBox"
+#define DefaultCMYK "DefaultCMYK"
#define DeviceCMYK "DeviceCMYK"
#define MediaBox "MediaBox"
#define RenderPostscriptText "Rendering Postscript... "
@@ -374,7 +383,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Open image file.
*/
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
@@ -394,35 +403,41 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
- if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
+ if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
{
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
+ 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->y_resolution=image->x_resolution;
+ 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 PDF media box.
*/
cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
- cropbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-cropbox");
- if (option != (const char *) NULL)
- cropbox=IsMagickTrue(option);
- trimbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-trimbox");
- if (option != (const char *) NULL)
- trimbox=IsMagickTrue(option);
+ cropbox=IsStringTrue(GetImageOption(image_info,"pdf:use-cropbox"));
+ trimbox=IsStringTrue(GetImageOption(image_info,"pdf:use-trimbox"));
count=0;
spotcolor=0;
(void) ResetMagickMemory(&bounding_box,0,sizeof(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));
- hires_bounds.x2=0.0;
- hires_bounds.y2=0.0;
angle=0.0;
p=command;
for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
@@ -443,8 +458,12 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Is this a CMYK document?
*/
+ if (LocaleNCompare(DefaultCMYK,command,strlen(DefaultCMYK)) == 0)
+ cmyk=MagickTrue;
if (LocaleNCompare(DeviceCMYK,command,strlen(DeviceCMYK)) == 0)
cmyk=MagickTrue;
+ if (LocaleNCompare(CMYKProcessColor,command,strlen(CMYKProcessColor)) == 0)
+ cmyk=MagickTrue;
if (LocaleNCompare(SpotColor,command,strlen(SpotColor)) == 0)
{
char
@@ -458,7 +477,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Note spot names.
*/
- (void) FormatMagickString(property,MaxTextExtent,"pdf:SpotColor-%.20g",
+ (void) FormatLocaleString(property,MaxTextExtent,"pdf:SpotColor-%.20g",
(double) spotcolor++);
i=0;
for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
@@ -470,12 +489,14 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
name[i]='\0';
value=AcquireString(name);
(void) SubstituteString(&value,"#20"," ");
- (void) SetImageProperty(image,property,value);
+ (void) SetImageProperty(image,property,value,exception);
value=DestroyString(value);
continue;
}
if (LocaleNCompare(PDFVersion,command,strlen(PDFVersion)) == 0)
- (void) SetImageProperty(image,"pdf:Version",command);
+ (void) SetImageProperty(image,"pdf:Version",command,exception);
+ if (image_info->page != (char *) NULL)
+ continue;
count=0;
if (cropbox != MagickFalse)
{
@@ -520,21 +541,26 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
}
if (count != 4)
continue;
- if (((bounds.x2 > hires_bounds.x2) && (bounds.y2 > hires_bounds.y2)) ||
- ((hires_bounds.x2 == 0.0) && (hires_bounds.y2 == 0.0)))
- {
- /*
- Set PDF render geometry.
- */
- (void) FormatMagickString(geometry,MaxTextExtent,
- "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
- bounds.x1,bounds.y1);
- (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry);
- page.width=(size_t) floor(bounds.x2-bounds.x1+0.5);
- page.height=(size_t) floor(bounds.y2-bounds.y1+0.5);
- hires_bounds=bounds;
- }
+ if ((fabs(bounds.x2-bounds.x1) <= fabs(hires_bounds.x2-hires_bounds.x1)) ||
+ (fabs(bounds.y2-bounds.y1) <= fabs(hires_bounds.y2-hires_bounds.y1)))
+ continue;
+ hires_bounds=bounds;
}
+ if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) &&
+ (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
+ {
+ /*
+ Set PDF render geometry.
+ */
+ (void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+.15g%+.15g",
+ hires_bounds.x2-bounds.x1,hires_bounds.y2-hires_bounds.y1,
+ hires_bounds.x1,hires_bounds.y1);
+ (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry,exception);
+ 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 ((fabs(angle) == 90.0) || (fabs(angle) == 270.0))
{
@@ -545,7 +571,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
page.width=page.height;
page.height=swap;
}
- if (image_info->colorspace == RGBColorspace)
+ if (IssRGBCompatibleColorspace(image_info->colorspace) != MagickFalse)
cmyk=MagickFalse;
/*
Create Ghostscript control file.
@@ -578,26 +604,11 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
return((Image *) NULL);
}
*options='\0';
- if (image_info->density != (char *) NULL)
- {
- flags=ParseGeometry(image_info->density,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
- if ((flags & SigmaValue) == 0)
- image->y_resolution=image->x_resolution;
- }
- (void) FormatMagickString(density,MaxTextExtent,"%gx%g",image->x_resolution,
- image->y_resolution);
+ (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->x_resolution/
- delta.x)+0.5);
- page.height=(size_t) floor((double) (page.height*image->y_resolution/
- delta.y)+0.5);
- (void) FormatMagickString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
- page.width,(double) page.height);
- }
+ (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
+ page.width,(double) page.height);
if (cmyk != MagickFalse)
(void) ConcatenateMagickString(options,"-dUseCIEColor ",MaxTextExtent);
if (cropbox != MagickFalse)
@@ -611,7 +622,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
char
pages[MaxTextExtent];
- (void) FormatMagickString(pages,MaxTextExtent,"-dFirstPage=%.20g "
+ (void) FormatLocaleString(pages,MaxTextExtent,"-dFirstPage=%.20g "
"-dLastPage=%.20g",(double) read_info->scene+1,(double)
(read_info->scene+read_info->number_scenes));
(void) ConcatenateMagickString(options,pages,MaxTextExtent);
@@ -619,13 +630,14 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (read_info->scenes != (char *) NULL)
*read_info->scenes='\0';
}
- if (read_info->authenticate != (char *) NULL)
- (void) FormatMagickString(options+strlen(options),MaxTextExtent,
- " -sPDFPassword=%s",read_info->authenticate);
+ option=GetImageOption(read_info,"authenticate");
+ if (option != (const char *) NULL)
+ (void) FormatLocaleString(options+strlen(options),MaxTextExtent,
+ " -sPCLPassword=%s",option);
(void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
(void) AcquireUniqueFilename(filename);
- (void) ConcatenateMagickString(filename,"-%08d",MaxTextExtent);
- (void) FormatMagickString(command,MaxTextExtent,
+ (void) ConcatenateMagickString(filename,"%d",MaxTextExtent);
+ (void) FormatLocaleString(command,MaxTextExtent,
GetDelegateCommands(delegate_info),
read_info->antialias != MagickFalse ? 4 : 1,
read_info->antialias != MagickFalse ? 4 : 1,density,options,filename,
@@ -638,7 +650,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
for (i=1; ; i++)
{
(void) InterpretImageFilename(image_info,image,filename,(int) i,
- read_info->filename);
+ read_info->filename,exception);
if (IsPDFRendered(read_info->filename) == MagickFalse)
break;
(void) RelinquishUniqueFileResource(read_info->filename);
@@ -647,9 +659,11 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
for (i=1; ; i++)
{
(void) InterpretImageFilename(image_info,image,filename,(int) i,
- read_info->filename);
+ read_info->filename,exception);
if (IsPDFRendered(read_info->filename) == MagickFalse)
break;
+ read_info->blob=NULL;
+ read_info->length=0;
next=ReadImage(read_info,exception);
(void) RelinquishUniqueFileResource(read_info->filename);
if (next == (Image *) NULL)
@@ -748,7 +762,6 @@ ModuleExport size_t RegisterPDFImage(void)
entry->adjoin=MagickFalse;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("Adobe Illustrator CS2");
entry->module=ConstantString("PDF");
(void) RegisterMagickInfo(entry);
@@ -758,7 +771,6 @@ ModuleExport size_t RegisterPDFImage(void)
entry->adjoin=MagickFalse;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("Encapsulated Portable Document Format");
entry->module=ConstantString("PDF");
(void) RegisterMagickInfo(entry);
@@ -768,7 +780,6 @@ ModuleExport size_t RegisterPDFImage(void)
entry->magick=(IsImageFormatHandler *) IsPDF;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("Portable Document Format");
entry->module=ConstantString("PDF");
(void) RegisterMagickInfo(entry);
@@ -778,7 +789,6 @@ ModuleExport size_t RegisterPDFImage(void)
entry->magick=(IsImageFormatHandler *) IsPDF;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("Portable Document Archive Format");
entry->module=ConstantString("PDF");
(void) RegisterMagickInfo(entry);
@@ -828,7 +838,8 @@ ModuleExport void UnregisterPDFImage(void)
%
% The format of the WritePDFImage method is:
%
-% MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WritePDFImage(const ImageInfo *image_info,
+% Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
@@ -836,6 +847,8 @@ ModuleExport void UnregisterPDFImage(void)
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static inline size_t MagickMax(const size_t x,const size_t y)
@@ -882,7 +895,7 @@ static char *EscapeParenthesis(const char *text)
}
static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
- Image *image,Image *inject_image)
+ Image *image,Image *inject_image,ExceptionInfo *exception)
{
Image
*group4_image;
@@ -903,11 +916,11 @@ static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
write_info=CloneImageInfo(image_info);
(void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent);
(void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent);
- group4_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception);
+ group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
if (group4_image == (Image *) NULL)
return(MagickFalse);
group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
- &image->exception);
+ exception);
group4_image=DestroyImage(group4_image);
if (group4 == (unsigned char *) NULL)
return(MagickFalse);
@@ -918,7 +931,8 @@ static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
return(status);
}
-static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
+static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image,
+ ExceptionInfo *exception)
{
#define CFormat "/Filter [ /%s ]\n"
#define ObjectsPerImage 14
@@ -939,6 +953,11 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
" \n"
" application/pdf\n"
+ " \n"
+ " \n"
+ " %s\n"
+ " \n"
+ " \n"
" \n"
" \n"
@@ -951,7 +970,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
" \n"
" \n"
- " 1\n"
+ " 2\n"
" B\n"
" \n"
" \n"
@@ -1007,10 +1026,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
media_info,
page_info;
- register const IndexPacket
- *indexes;
-
- register const PixelPacket
+ register const Quantum
*p;
register unsigned char
@@ -1051,7 +1067,9 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
/*
@@ -1069,12 +1087,12 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
if (image_info->compression == JPEG2000Compression)
version=(size_t) MagickMax(version,5);
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
- if (next->matte != MagickFalse)
+ if (next->alpha_trait == BlendPixelTrait)
version=(size_t) MagickMax(version,4);
if (LocaleCompare(image_info->magick,"PDFA") == 0)
version=(size_t) MagickMax(version,6);
- (void) FormatMagickString(buffer,MaxTextExtent,"%%PDF-1.%.20g \n",
- (double) version);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%%PDF-1.%.20g \n",(double)
+ version);
(void) WriteBlobString(image,buffer);
if (LocaleCompare(image_info->magick,"PDFA") == 0)
(void) WriteBlobString(image,"%âãÏÓ\n");
@@ -1083,25 +1101,26 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
*/
xref[object++]=TellBlob(image);
root_id=object;
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
if (LocaleCompare(image_info->magick,"PDFA") != 0)
- (void) FormatMagickString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",
- (double) object+1);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",(double)
+ object+1);
else
{
- (void) FormatMagickString(buffer,MaxTextExtent,"/Metadata %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Metadata %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",
(double) object+2);
}
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/Type /Catalog\n");
(void) WriteBlobString(image,">>\n");
(void) WriteBlobString(image,"endobj\n");
+ GetPathComponent(image->filename,BasePath,basename);
if (LocaleCompare(image_info->magick,"PDFA") == 0)
{
char
@@ -1117,30 +1136,31 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write XMP object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
- (double) object);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
(void) WriteBlobString(image,"/Subtype /XML\n");
*modify_date='\0';
- value=GetImageProperty(image,"date:modify");
+ value=GetImageProperty(image,"date:modify",exception);
if (value != (const char *) NULL)
(void) CopyMagickString(modify_date,value,MaxTextExtent);
*create_date='\0';
- value=GetImageProperty(image,"date:create");
+ value=GetImageProperty(image,"date:create",exception);
if (value != (const char *) NULL)
(void) CopyMagickString(create_date,value,MaxTextExtent);
(void) FormatMagickTime(time((time_t *) NULL),MaxTextExtent,timestamp);
- i=FormatMagickString(xmp_profile,MaxTextExtent,XMPProfile,
+ i=FormatLocaleString(xmp_profile,MaxTextExtent,XMPProfile,
XMPProfileMagick,modify_date,create_date,timestamp,
- GetMagickVersion(&version),GetMagickVersion(&version));
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g\n",
- (double) i);
+ GetMagickVersion(&version),EscapeParenthesis(basename),
+ GetMagickVersion(&version));
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g\n",(double)
+ i);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/Type /Metadata\n");
(void) WriteBlobString(image,">>\nstream\n");
(void) WriteBlobString(image,xmp_profile);
- (void) WriteBlobString(image,"endstream\n");
+ (void) WriteBlobString(image,"\nendstream\n");
(void) WriteBlobString(image,"endobj\n");
}
/*
@@ -1148,13 +1168,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
*/
xref[object++]=TellBlob(image);
pages_id=object;
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
(void) WriteBlobString(image,"/Type /Pages\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Kids [ %.20g 0 R ",
- (double) object+1);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Kids [ %.20g 0 R ",(double)
+ object+1);
(void) WriteBlobString(image,buffer);
count=(ssize_t) (pages_id+ObjectsPerImage+1);
if (image_info->adjoin != MagickFalse)
@@ -1168,7 +1188,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
kid_image=image;
for ( ; GetNextImageInList(kid_image) != (Image *) NULL; count+=ObjectsPerImage)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 R ",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 R ",(double)
count);
(void) WriteBlobString(image,buffer);
kid_image=GetNextImageInList(kid_image);
@@ -1179,8 +1199,8 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
(void) WriteBlobString(image,"]\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Count %.20g\n",
- (double) ((count-pages_id)/ObjectsPerImage));
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Count %.20g\n",(double)
+ ((count-pages_id)/ObjectsPerImage));
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
(void) WriteBlobString(image,"endobj\n");
@@ -1195,8 +1215,8 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
case FaxCompression:
case Group4Compression:
{
- if ((IsMonochromeImage(image,&image->exception) == MagickFalse) ||
- (image->matte != MagickFalse))
+ if ((IsImageMonochrome(image,exception) == MagickFalse) ||
+ (image->alpha_trait == BlendPixelTrait))
compression=RLECompression;
break;
}
@@ -1204,7 +1224,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
case JPEGCompression:
{
compression=RLECompression;
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (JPEG)",
image->filename);
break;
@@ -1214,7 +1234,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
case JPEG2000Compression:
{
compression=RLECompression;
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (JP2)",
image->filename);
break;
@@ -1224,7 +1244,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
case ZipCompression:
{
compression=RLECompression;
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (ZLIB)",
image->filename);
break;
@@ -1247,16 +1267,16 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
if (compression == JPEG2000Compression)
{
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
}
/*
Scale relative to dots-per-inch.
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
- resolution.x=image->x_resolution;
- resolution.y=image->y_resolution;
+ resolution.x=image->resolution.x;
+ resolution.y=image->resolution.y;
if ((resolution.x == 0.0) || (resolution.y == 0.0))
{
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
@@ -1279,16 +1299,15 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
resolution.y=(double) ((size_t) (100.0*2.54*resolution.y+0.5)/100.0);
}
SetGeometry(image,&geometry);
- (void) FormatMagickString(page_geometry,MaxTextExtent,"%.20gx%.20g",
- (double) image->columns,(double) image->rows);
+ (void) FormatLocaleString(page_geometry,MaxTextExtent,"%.20gx%.20g",(double)
+ image->columns,(double) image->rows);
if (image_info->page != (char *) NULL)
(void) CopyMagickString(page_geometry,image_info->page,MaxTextExtent);
else
if ((image->page.width != 0) && (image->page.height != 0))
- (void) FormatMagickString(page_geometry,MaxTextExtent,
- "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
- (double) image->page.height,(double) image->page.x,(double)
- image->page.y);
+ (void) FormatLocaleString(page_geometry,MaxTextExtent,
+ "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double)
+ image->page.height,(double) image->page.x,(double) image->page.y);
else
if ((image->gravity != UndefinedGravity) &&
(LocaleCompare(image_info->magick,"PDF") == 0))
@@ -1301,8 +1320,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
scale.y=(double) (geometry.height*delta.y)/resolution.y;
geometry.height=(size_t) floor(scale.y+0.5);
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
- (void) ParseGravityGeometry(image,page_geometry,&page_info,
- &image->exception);
+ (void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
if (image->gravity != UndefinedGravity)
{
geometry.x=(-page_info.x);
@@ -1312,7 +1330,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
if (image_info->pointsize != 0.0)
pointsize=image_info->pointsize;
text_size=0;
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
text_size=(size_t) (MultilineCensus(value)*pointsize+12);
(void) text_size;
@@ -1320,46 +1338,46 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Page object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
(void) WriteBlobString(image,"/Type /Page\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Parent %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Parent %.20g 0 R\n",
(double) pages_id);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/Resources <<\n");
labels=(char **) NULL;
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
labels=StringToList(value);
if (labels != (char **) NULL)
{
- (void) FormatMagickString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MaxTextExtent,
"/Font << /F%.20g %.20g 0 R >>\n",(double) image->scene,(double)
object+4);
(void) WriteBlobString(image,buffer);
}
- (void) FormatMagickString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MaxTextExtent,
"/XObject << /Im%.20g %.20g 0 R >>\n",(double) image->scene,(double)
object+5);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/ProcSet %.20g 0 R >>\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/ProcSet %.20g 0 R >>\n",
(double) object+3);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MaxTextExtent,
"/MediaBox [0 0 %g %g]\n",72.0*media_info.width/resolution.x,
72.0*media_info.height/resolution.y);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MaxTextExtent,
"/CropBox [0 0 %g %g]\n",72.0*media_info.width/resolution.x,
72.0*media_info.height/resolution.y);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Contents %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Contents %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Thumb %.20g 0 R\n",
- (double) object+8);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Thumb %.20g 0 R\n",(double)
+ object+8);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
(void) WriteBlobString(image,"endobj\n");
@@ -1367,11 +1385,11 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Contents object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -1382,44 +1400,44 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (i=0; labels[i] != (char *) NULL; i++)
{
(void) WriteBlobString(image,"BT\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/F%.20g %g Tf\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/F%.20g %g Tf\n",
(double) image->scene,pointsize);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g %.20g Td\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g Td\n",
(double) geometry.x,(double) (geometry.y+geometry.height+i*pointsize+
12));
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"(%s) Tj\n",labels[i]);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"(%s) Tj\n",labels[i]);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"ET\n");
labels[i]=DestroyString(labels[i]);
}
- (void) FormatMagickString(buffer,MaxTextExtent,"%g 0 0 %g %.20g %.20g cm\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%g 0 0 %g %.20g %.20g cm\n",
scale.x,scale.y,(double) geometry.x,(double) geometry.y);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Im%.20g Do\n",
- (double) image->scene);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Im%.20g Do\n",(double)
+ image->scene);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"Q\n");
offset=TellBlob(image)-offset;
- (void) WriteBlobString(image,"endstream\n");
+ (void) WriteBlobString(image,"\nendstream\n");
(void) WriteBlobString(image,"endobj\n");
/*
Write Length object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"endobj\n");
/*
Write Procset object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
- (double) object);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ object);
(void) WriteBlobString(image,buffer);
if ((image->storage_class == DirectClass) || (image->colors > 256))
(void) CopyMagickString(buffer,"[ /PDF /Text /ImageC",MaxTextExtent);
@@ -1435,15 +1453,15 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Font object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
- (double) object);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
if (labels != (char **) NULL)
{
(void) WriteBlobString(image,"/Type /Font\n");
(void) WriteBlobString(image,"/Subtype /Type1\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Name /F%.20g\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Name /F%.20g\n",
(double) image->scene);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/BaseFont /Helvetica\n");
@@ -1456,25 +1474,25 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write XObject object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
(void) WriteBlobString(image,"/Type /XObject\n");
(void) WriteBlobString(image,"/Subtype /Image\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Name /Im%.20g\n",
- (double) image->scene);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Name /Im%.20g\n",(double)
+ image->scene);
(void) WriteBlobString(image,buffer);
switch (compression)
{
case NoCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"ASCII85Decode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"ASCII85Decode");
break;
}
case JPEGCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"DCTDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"DCTDecode");
if (image->colorspace != CMYKColorspace)
break;
(void) WriteBlobString(image,buffer);
@@ -1484,7 +1502,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
case JPEG2000Compression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"JPXDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"JPXDecode");
if (image->colorspace != CMYKColorspace)
break;
(void) WriteBlobString(image,buffer);
@@ -1494,12 +1512,12 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
case LZWCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"LZWDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"LZWDecode");
break;
}
case ZipCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"FlateDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"FlateDecode");
break;
}
case FaxCompression:
@@ -1508,39 +1526,39 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
(void) CopyMagickString(buffer,"/Filter [ /CCITTFaxDecode ]\n",
MaxTextExtent);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << "
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/DecodeParms [ << "
"/K %s /BlackIs1 false /Columns %.20g /Rows %.20g >> ]\n",CCITTParam,
(double) image->columns,(double) image->rows);
break;
}
default:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,
"RunLengthDecode");
break;
}
}
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
image->columns);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
image->rows);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
(double) object+2);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
(compression == FaxCompression) || (compression == Group4Compression) ?
1 : 8);
(void) WriteBlobString(image,buffer);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"/SMask %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/SMask %.20g 0 R\n",
(double) object+7);
(void) WriteBlobString(image,buffer);
}
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -1551,7 +1569,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
if ((compression == FaxCompression) || (compression == Group4Compression) ||
((image_info->type != TrueColorType) &&
- (IsGrayImage(image,&image->exception) != MagickFalse)))
+ (IsImageGray(image,exception) != MagickFalse)))
{
switch (compression)
{
@@ -1560,26 +1578,30 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
{
if (LocaleCompare(CCITTParam,"0") == 0)
{
- (void) HuffmanEncodeImage(image_info,image,image);
+ (void) HuffmanEncodeImage(image_info,image,image,exception);
break;
}
- (void) Huffman2DEncodeImage(image_info,image,image);
+ (void) Huffman2DEncodeImage(image_info,image,image,exception);
break;
}
case JPEGCompression:
{
- status=InjectImageBlob(image_info,image,image,"jpeg",
- &image->exception);
+ status=InjectImageBlob(image_info,image,image,"jpeg",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case JPEG2000Compression:
{
- status=InjectImageBlob(image_info,image,image,"jp2",
- &image->exception);
+ status=InjectImageBlob(image_info,image,image,"jp2",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case RLECompression:
@@ -1599,13 +1621,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
q=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelIntensity(image,p));
+ p+=GetPixelChannels(image);
}
if (image->previous == (Image *) NULL)
{
@@ -1617,13 +1639,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -1640,14 +1662,14 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Ascii85Initialize(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- Ascii85Encode(image,
- ScaleQuantumToChar(PixelIntensityToQuantum(p)));
- p++;
+ Ascii85Encode(image,ScaleQuantumToChar(
+ GetPixelIntensity(image,p)));
+ p+=GetPixelChannels(image);
}
if (image->previous == (Image *) NULL)
{
@@ -1670,18 +1692,22 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
{
case JPEGCompression:
{
- status=InjectImageBlob(image_info,image,image,"jpeg",
- &image->exception);
+ status=InjectImageBlob(image_info,image,image,"jpeg",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case JPEG2000Compression:
{
- status=InjectImageBlob(image_info,image,image,"jp2",
- &image->exception);
+ status=InjectImageBlob(image_info,image,image,"jp2",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case RLECompression:
@@ -1702,18 +1728,17 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
q=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
{
- *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
- *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
- *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
+ *q++=ScaleQuantumToChar(GetPixelRed(image,p));
+ *q++=ScaleQuantumToChar(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToChar(GetPixelBlue(image,p));
if (image->colorspace == CMYKColorspace)
- *q++=ScaleQuantumToChar(GetIndexPixelComponent(indexes+x));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelBlack(image,p));
+ p+=GetPixelChannels(image);
}
if (image->previous == (Image *) NULL)
{
@@ -1725,13 +1750,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -1748,22 +1773,18 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Ascii85Initialize(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
{
- Ascii85Encode(image,ScaleQuantumToChar(
- GetRedPixelComponent(p)));
- Ascii85Encode(image,ScaleQuantumToChar(
- GetGreenPixelComponent(p)));
- Ascii85Encode(image,ScaleQuantumToChar(
- GetBluePixelComponent(p)));
+ Ascii85Encode(image,ScaleQuantumToChar(GetPixelRed(image,p)));
+ Ascii85Encode(image,ScaleQuantumToChar(GetPixelGreen(image,p)));
+ Ascii85Encode(image,ScaleQuantumToChar(GetPixelBlue(image,p)));
if (image->colorspace == CMYKColorspace)
Ascii85Encode(image,ScaleQuantumToChar(
- GetIndexPixelComponent(indexes+x)));
- p++;
+ GetPixelBlack(image,p)));
+ p+=GetPixelChannels(image);
}
if (image->previous == (Image *) NULL)
{
@@ -1802,13 +1823,14 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
q=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
- *q++=(unsigned char) GetIndexPixelComponent(indexes+x);
+ {
+ *q++=(unsigned char) GetPixelIndex(image,p);
+ p+=GetPixelChannels(image);
+ }
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,
@@ -1819,13 +1841,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -1842,14 +1864,14 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Ascii85Initialize(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
- Ascii85Encode(image,(unsigned char)
- GetIndexPixelComponent(indexes+x));
+ {
+ Ascii85Encode(image,(unsigned char) GetPixelIndex(image,p));
+ p+=GetPixelChannels(image);
+ }
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,
@@ -1870,18 +1892,17 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Length object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",
- (double) offset);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"endobj\n");
/*
Write Colorspace object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
if (image->colorspace == CMYKColorspace)
@@ -1890,7 +1911,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
if ((compression == FaxCompression) ||
(compression == Group4Compression) ||
((image_info->type != TrueColorType) &&
- (IsGrayImage(image,&image->exception) != MagickFalse)))
+ (IsImageGray(image,exception) != MagickFalse)))
(void) CopyMagickString(buffer,"/DeviceGray\n",MaxTextExtent);
else
if ((image->storage_class == DirectClass) || (image->colors > 256) ||
@@ -1898,7 +1919,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
(compression == JPEG2000Compression))
(void) CopyMagickString(buffer,"/DeviceRGB\n",MaxTextExtent);
else
- (void) FormatMagickString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MaxTextExtent,
"[ /Indexed /DeviceRGB %.20g %.20g 0 R ]\n",(double) image->colors-
1,(double) object+3);
(void) WriteBlobString(image,buffer);
@@ -1909,12 +1930,11 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
SetGeometry(image,&geometry);
(void) ParseMetaGeometry("106x106+0+0>",&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
- tile_image=ThumbnailImage(image,geometry.width,geometry.height,
- &image->exception);
+ tile_image=ThumbnailImage(image,geometry.width,geometry.height,exception);
if (tile_image == (Image *) NULL)
- ThrowWriterException(ResourceLimitError,image->exception.reason);
+ return(MagickFalse);
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
@@ -1922,12 +1942,12 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
{
case NoCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"ASCII85Decode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"ASCII85Decode");
break;
}
case JPEGCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"DCTDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"DCTDecode");
if (image->colorspace != CMYKColorspace)
break;
(void) WriteBlobString(image,buffer);
@@ -1937,7 +1957,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
case JPEG2000Compression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"JPXDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"JPXDecode");
if (image->colorspace != CMYKColorspace)
break;
(void) WriteBlobString(image,buffer);
@@ -1947,12 +1967,12 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
}
case LZWCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"LZWDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"LZWDecode");
break;
}
case ZipCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"FlateDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"FlateDecode");
break;
}
case FaxCompression:
@@ -1961,33 +1981,33 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
(void) CopyMagickString(buffer,"/Filter [ /CCITTFaxDecode ]\n",
MaxTextExtent);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << "
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/DecodeParms [ << "
"/K %s /BlackIs1 false /Columns %.20g /Rows %.20g >> ]\n",CCITTParam,
(double) tile_image->columns,(double) tile_image->rows);
break;
}
default:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,
"RunLengthDecode");
break;
}
}
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
tile_image->columns);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
tile_image->rows);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
(double) object-1);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
(compression == FaxCompression) || (compression == Group4Compression) ?
1 : 8);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -1997,7 +2017,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
if ((compression == FaxCompression) ||
(compression == Group4Compression) ||
((image_info->type != TrueColorType) &&
- (IsGrayImage(tile_image,&image->exception) != MagickFalse)))
+ (IsImageGray(tile_image,exception) != MagickFalse)))
{
switch (compression)
{
@@ -2006,26 +2026,32 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
{
if (LocaleCompare(CCITTParam,"0") == 0)
{
- (void) HuffmanEncodeImage(image_info,image,tile_image);
+ (void) HuffmanEncodeImage(image_info,image,tile_image,
+ exception);
break;
}
- (void) Huffman2DEncodeImage(image_info,image,tile_image);
+ (void) Huffman2DEncodeImage(image_info,image,tile_image,exception);
break;
}
case JPEGCompression:
{
status=InjectImageBlob(image_info,image,tile_image,"jpeg",
- &image->exception);
+ exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,tile_image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case JPEG2000Compression:
{
- status=InjectImageBlob(image_info,image,tile_image,"jp2",
- &image->exception);
+ status=InjectImageBlob(image_info,image,tile_image,"jp2",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,tile_image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case RLECompression:
@@ -2050,24 +2076,24 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
- *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelIntensity(tile_image,p));
+ p+=GetPixelChannels(tile_image);
}
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -2085,14 +2111,14 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
Ascii85Encode(image,
- ScaleQuantumToChar(PixelIntensityToQuantum(p)));
- p++;
+ ScaleQuantumToChar(GetPixelIntensity(tile_image,p)));
+ p+=GetPixelChannels(tile_image);
}
}
Ascii85Flush(image);
@@ -2109,17 +2135,22 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
case JPEGCompression:
{
status=InjectImageBlob(image_info,image,tile_image,"jpeg",
- &image->exception);
+ exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,tile_image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case JPEG2000Compression:
{
- status=InjectImageBlob(image_info,image,tile_image,"jp2",
- &image->exception);
+ status=InjectImageBlob(image_info,image,tile_image,"jp2",exception);
if (status == MagickFalse)
- ThrowWriterException(CoderError,tile_image->exception.reason);
+ {
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
break;
}
case RLECompression:
@@ -2145,29 +2176,28 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(tile_image);
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
- *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
- *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
- *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
+ *q++=ScaleQuantumToChar(GetPixelRed(tile_image,p));
+ *q++=ScaleQuantumToChar(GetPixelGreen(tile_image,p));
+ *q++=ScaleQuantumToChar(GetPixelBlue(tile_image,p));
if (image->colorspace == CMYKColorspace)
- *q++=ScaleQuantumToChar(GetIndexPixelComponent(indexes+x));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelBlack(tile_image,p));
+ p+=GetPixelChannels(tile_image);
}
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -2185,22 +2215,21 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(tile_image);
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
Ascii85Encode(image,ScaleQuantumToChar(
- GetRedPixelComponent(p)));
+ GetPixelRed(tile_image,p)));
Ascii85Encode(image,ScaleQuantumToChar(
- GetGreenPixelComponent(p)));
+ GetPixelGreen(tile_image,p)));
Ascii85Encode(image,ScaleQuantumToChar(
- GetBluePixelComponent(p)));
+ GetPixelBlue(tile_image,p)));
if (image->colorspace == CMYKColorspace)
Ascii85Encode(image,ScaleQuantumToChar(
- GetIndexPixelComponent(indexes+x)));
- p++;
+ GetPixelBlack(tile_image,p)));
+ p+=GetPixelChannels(tile_image);
}
}
Ascii85Flush(image);
@@ -2236,22 +2265,24 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(tile_image);
for (x=0; x < (ssize_t) tile_image->columns; x++)
- *q++=(unsigned char) GetIndexPixelComponent(indexes+x);
+ {
+ *q++=(unsigned char) GetPixelIndex(tile_image,p);
+ p+=GetPixelChannels(tile_image);
+ }
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -2269,13 +2300,15 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
- &tile_image->exception);
- if (p == (const PixelPacket *) NULL)
+ exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(tile_image);
for (x=0; x < (ssize_t) tile_image->columns; x++)
+ {
Ascii85Encode(image,(unsigned char)
- GetIndexPixelComponent(indexes+x));
+ GetPixelIndex(tile_image,p));
+ p+=GetPixelChannels(image);
+ }
}
Ascii85Flush(image);
break;
@@ -2290,26 +2323,28 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Length object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"endobj\n");
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- if ((image->storage_class != DirectClass) && (image->colors <= 256) &&
- (compression != FaxCompression) && (compression != Group4Compression))
+ (void) WriteBlobString(image,"<<\n");
+ if ((image->storage_class == DirectClass) || (image->colors > 256) ||
+ (compression == FaxCompression) || (compression == Group4Compression))
+ (void) WriteBlobString(image,">>\n");
+ else
{
/*
Write Colormap object.
*/
- (void) WriteBlobString(image,"<<\n");
if (compression == NoCompression)
(void) WriteBlobString(image,"/Filter [ /ASCII85Decode ]\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -2343,10 +2378,10 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Length object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double)
offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"endobj\n");
@@ -2354,58 +2389,58 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write softmask object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
- if (image->matte == MagickFalse)
+ if (image->alpha_trait != BlendPixelTrait)
(void) WriteBlobString(image,">>\n");
else
{
(void) WriteBlobString(image,"/Type /XObject\n");
(void) WriteBlobString(image,"/Subtype /Image\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Name /Ma%.20g\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Name /Ma%.20g\n",
(double) image->scene);
(void) WriteBlobString(image,buffer);
switch (compression)
{
case NoCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,
"ASCII85Decode");
break;
}
case LZWCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,"LZWDecode");
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,"LZWDecode");
break;
}
case ZipCompression:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,
"FlateDecode");
break;
}
default:
{
- (void) FormatMagickString(buffer,MaxTextExtent,CFormat,
+ (void) FormatLocaleString(buffer,MaxTextExtent,CFormat,
"RunLengthDecode");
break;
}
}
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",
- (double) image->columns);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
+ image->columns);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Height %.20g\n",
(double) image->rows);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/ColorSpace /DeviceGray\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
(compression == FaxCompression) || (compression == Group4Compression)
? 1 : 8);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
(double) object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -2435,24 +2470,24 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
q=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelAlpha(image,p));
+ p+=GetPixelChannels(image);
}
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
@@ -2469,14 +2504,13 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Ascii85Initialize(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- Ascii85Encode(image,ScaleQuantumToChar((Quantum) (QuantumRange-
- GetOpacityPixelComponent(p))));
- p++;
+ Ascii85Encode(image,ScaleQuantumToChar(GetPixelAlpha(image,p)));
+ p+=GetPixelChannels(image);
}
}
Ascii85Flush(image);
@@ -2491,10 +2525,10 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
Write Length object.
*/
xref[object++]=TellBlob(image);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"endobj\n");
if (GetNextImageInList(image) == (Image *) NULL)
@@ -2510,12 +2544,11 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
*/
xref[object++]=TellBlob(image);
info_id=object;
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
object);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"<<\n");
- GetPathComponent(image->filename,BasePath,basename);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Title (%s)\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Title (%s)\n",
EscapeParenthesis(basename));
(void) WriteBlobString(image,buffer);
seconds=time((time_t *) NULL);
@@ -2524,14 +2557,14 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
#else
(void) memcpy(&local_time,localtime(&seconds),sizeof(local_time));
#endif
- (void) FormatMagickString(date,MaxTextExtent,"D:%04d%02d%02d%02d%02d%02d",
+ (void) FormatLocaleString(date,MaxTextExtent,"D:%04d%02d%02d%02d%02d%02d",
local_time.tm_year+1900,local_time.tm_mon+1,local_time.tm_mday,
local_time.tm_hour,local_time.tm_min,local_time.tm_sec);
- (void) FormatMagickString(buffer,MaxTextExtent,"/CreationDate (%s)\n",date);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/CreationDate (%s)\n",date);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/ModDate (%s)\n",date);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/ModDate (%s)\n",date);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Producer (%s)\n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Producer (%s)\n",
EscapeParenthesis(GetMagickVersion((size_t *) NULL)));
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
@@ -2539,32 +2572,38 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
/*
Write Xref object.
*/
- offset=TellBlob(image)-xref[0]+10;
+ offset=TellBlob(image)-xref[0]+
+ (LocaleCompare(image_info->magick,"PDFA") == 0 ? 6 : 0)+10;
(void) WriteBlobString(image,"xref\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"0 %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"0 %.20g\n",(double)
object+1);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"0000000000 65535 f \n");
for (i=0; i < (ssize_t) object; i++)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"%010lu 00000 n \n",
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%010lu 00000 n \n",
(unsigned long) xref[i]);
(void) WriteBlobString(image,buffer);
}
(void) WriteBlobString(image,"trailer\n");
(void) WriteBlobString(image,"<<\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"/Size %.20g\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Size %.20g\n",(double)
object+1);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Info %.20g 0 R\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Info %.20g 0 R\n",(double)
info_id);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"/Root %.20g 0 R\n",(double)
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/Root %.20g 0 R\n",(double)
root_id);
(void) WriteBlobString(image,buffer);
+ (void) SignatureImage(image,exception);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"/ID [<%s> <%s>]\n",
+ GetImageProperty(image,"signature",exception),
+ GetImageProperty(image,"signature",exception));
+ (void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,">>\n");
(void) WriteBlobString(image,"startxref\n");
- (void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"%%EOF\n");
xref=(MagickOffsetType *) RelinquishMagickMemory(xref);