% Read/Write Microsoft XML Paper Specification Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% January 2008 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 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 %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
/*
Include declarations.
*/
-#include "magick/studio.h"
-#include "magick/property.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/color.h"
-#include "magick/color-private.h"
-#include "magick/colorspace.h"
-#include "magick/constitute.h"
-#include "magick/delegate.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/profile.h"
-#include "magick/resource_.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/token.h"
-#include "magick/transform.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/artifact.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/delegate.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/profile.h"
+#include "MagickCore/property.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/quantum-private.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"
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#define RenderXPSText " Rendering XPS... "
char
- command[MaxTextExtent],
- density[MaxTextExtent],
- filename[MaxTextExtent],
- geometry[MaxTextExtent],
- options[MaxTextExtent],
- input_filename[MaxTextExtent];
+ command[MagickPathExtent],
+ *density,
+ filename[MagickPathExtent],
+ geometry[MagickPathExtent],
+ *options,
+ input_filename[MagickPathExtent];
const DelegateInfo
*delegate_info;
register char
*p;
- register long
+ register ssize_t
c;
SegmentInfo
bounds;
- ssize_t
- count;
-
- unsigned long
+ size_t
height,
width;
+ ssize_t
+ count;
+
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
/*
Open image file.
*/
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
*/
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))
{
GeometryInfo
geometry_info;
flags;
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->y_resolution=image->x_resolution;
+ image->resolution.y=image->resolution.x;
}
- (void) FormatMagickString(density,MaxTextExtent,"%.15gx%.15g",
- image->x_resolution,image->y_resolution);
/*
Determine page geometry from the XPS media box.
*/
cmyk=image->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
count=0;
- (void) ResetMagickMemory(&bounding_box,0,sizeof(bounding_box));
- (void) ResetMagickMemory(&bounds,0,sizeof(bounds));
- (void) ResetMagickMemory(&page,0,sizeof(page));
- (void) ResetMagickMemory(command,0,sizeof(command));
+ (void) memset(&bounding_box,0,sizeof(bounding_box));
+ (void) memset(&bounds,0,sizeof(bounds));
+ (void) memset(&page,0,sizeof(page));
+ (void) memset(command,0,sizeof(command));
p=command;
for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
{
*/
*p++=(char) c;
if ((c != (int) '/') && (c != '\n') &&
- ((size_t) (p-command) < (MaxTextExtent-1)))
+ ((size_t) (p-command) < (MagickPathExtent-1)))
continue;
*p='\0';
p=command;
/*
Set XPS render geometry.
*/
- width=(unsigned long) (bounds.x2-bounds.x1+0.5);
- height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+ width=(size_t) (floor(bounds.x2+0.5)-ceil(bounds.x1-0.5));
+ height=(size_t) (floor(bounds.y2+0.5)-ceil(bounds.y1-0.5));
if (width > page.width)
page.width=width;
if (height > page.height)
(void) ParseAbsoluteGeometry(PSPageGeometry,&page);
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
- (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu",
- page.width,page.height);
+ (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g",(double)
+ page.width,(double) page.height);
if (image_info->monochrome != MagickFalse)
delegate_info=GetDelegateInfo("xps:mono",(char *) NULL,exception);
else
else
delegate_info=GetDelegateInfo("xps:color",(char *) NULL,exception);
if (delegate_info == (const DelegateInfo *) NULL)
- return((Image *) NULL);
- *options='\0';
+ {
+ image=DestroyImage(image);
+ return((Image *) NULL);
+ }
+ density=AcquireString("");
+ options=AcquireString("");
+ (void) FormatLocaleString(density,MagickPathExtent,"%gx%g",
+ image->resolution.x,image->resolution.y);
if ((page.width == 0) || (page.height == 0))
(void) ParseAbsoluteGeometry(PSPageGeometry,&page);
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
- page.width=(unsigned long) (page.width*image->y_resolution/delta.x+0.5);
- page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
- (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
- page.width,page.height);
+ page.width=(size_t) floor(page.width*image->resolution.y/delta.x+0.5);
+ page.height=(size_t) floor(page.height*image->resolution.y/delta.y+0.5);
+ (void) FormatLocaleString(options,MagickPathExtent,"-g%.20gx%.20g ",(double)
+ page.width,(double) page.height);
image=DestroyImage(image);
read_info=CloneImageInfo(image_info);
*read_info->magick='\0';
if (read_info->number_scenes != 0)
{
if (read_info->number_scenes != 1)
- (void) FormatMagickString(options,MaxTextExtent,"-dLastPage=%lu",
- read_info->scene+read_info->number_scenes);
+ (void) FormatLocaleString(options,MagickPathExtent,"-dLastPage=%.20g",
+ (double) (read_info->scene+read_info->number_scenes));
else
- (void) FormatMagickString(options,MaxTextExtent,
- "-dFirstPage=%lu -dLastPage=%lu",read_info->scene+1,read_info->scene+
- read_info->number_scenes);
+ (void) FormatLocaleString(options,MagickPathExtent,
+ "-dFirstPage=%.20g -dLastPage=%.20g",(double) read_info->scene+1,
+ (double) (read_info->scene+read_info->number_scenes));
read_info->number_scenes=0;
if (read_info->scenes != (char *) NULL)
*read_info->scenes='\0';
}
- if (read_info->authenticate != (char *) NULL)
- (void) FormatMagickString(options+strlen(options),MaxTextExtent,
- " -sXPSPassword=%s",read_info->authenticate);
- (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
+ (void) CopyMagickString(filename,read_info->filename,MagickPathExtent);
(void) AcquireUniqueFilename(read_info->filename);
- (void) FormatMagickString(command,MaxTextExtent,
+ (void) FormatLocaleString(command,MagickPathExtent,
GetDelegateCommands(delegate_info),
read_info->antialias != MagickFalse ? 4 : 1,
read_info->antialias != MagickFalse ? 4 : 1,density,options,
read_info->filename,input_filename);
- status=SystemCommand(read_info->verbose,command,exception) != 0 ? MagickTrue :
- MagickFalse;
+ options=DestroyString(options);
+ density=DestroyString(density);
+ status=ExternalDelegateCommand(MagickFalse,read_info->verbose,command,
+ (char *) NULL,exception) != 0 ? MagickTrue : MagickFalse;
image=ReadImage(read_info,exception);
(void) RelinquishUniqueFileResource(read_info->filename);
(void) RelinquishUniqueFileResource(input_filename);
Image
*cmyk_image;
- cmyk_image=ConsolidateCMYKImages(image,&image->exception);
+ cmyk_image=ConsolidateCMYKImages(image,exception);
if (cmyk_image != (Image *) NULL)
{
image=DestroyImageList(image);
}
do
{
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
image->page=page;
next_image=SyncNextImageInList(image);
if (next_image != (Image *) NULL)
%
% The format of the RegisterXPSImage method is:
%
-% unsigned long RegisterXPSImage(void)
+% size_t RegisterXPSImage(void)
%
*/
-ModuleExport unsigned long RegisterXPSImage(void)
+ModuleExport size_t RegisterXPSImage(void)
{
MagickInfo
*entry;
- entry=SetMagickInfo("XPS");
+ entry=AcquireMagickInfo("XPS","XPS","Microsoft XML Paper Specification");
entry->decoder=(DecodeImageHandler *) ReadXPSImage;
- entry->adjoin=MagickFalse;
- entry->blob_support=MagickFalse;
- entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
- entry->description=ConstantString("Microsoft XML Paper Specification");
- entry->module=ConstantString("XPS");
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags^=CoderBlobSupportFlag;
+ entry->flags^=CoderDecoderThreadSupportFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}