]> granicus.if.org Git - imagemagick/blobdiff - coders/pes.c
(no commit message)
[imagemagick] / coders / pes.c
index d82aeee8fa9868c989184386a795a29021214c91..cfce5c915cc61cecf6efd0c92fe439988b1c4bf7 100644 (file)
 %                     Read/Write Brother PES Image Format                     %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 2009                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2015 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  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/property.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/client.h"
-#include "magick/colorspace.h"
-#include "magick/constitute.h"
-#include "magick/decorate.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/gem.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/montage.h"
-#include "magick/resize.h"
-#include "magick/shear.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/resource_.h"
-#include "magick/transform.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/property.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/client.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/decorate.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/gem.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/montage.h"
+#include "MagickCore/resize.h"
+#include "MagickCore/shear.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/transform.h"
+#include "MagickCore/utility.h"
 \f
 /*
   Typedef declarations.
@@ -455,6 +455,11 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
   register ssize_t
     i;
 
+  size_t
+    number_blocks,
+    number_colors,
+    number_stitches;
+
   ssize_t
     count,
     offset;
@@ -463,11 +468,6 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
     magick[4],
     version[4];
 
-  size_t
-    number_blocks,
-    number_colors,
-    number_stitches;
-
   /*
     Open image file.
   */
@@ -478,7 +478,7 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     {
@@ -505,7 +505,7 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
   for (i=0; i < (ssize_t) number_colors; i++)
   {
     j=(int) ReadBlobByte(image);
-    blocks[i].color=PESColor+j;
+    blocks[i].color=PESColor+(j < 0 ? 0 : j);
     blocks[i].offset=0;
   }
   for ( ; i < 256L; i++)
@@ -626,8 +626,8 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
     file=fdopen(unique_file,"wb");
   if ((unique_file == -1) || (file == (FILE *) NULL))
     ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
-  (void) fprintf(file,"<?xml version=\"1.0\"?>\n");
-  (void) fprintf(file,"<svg xmlns=\"http://www.w3.org/2000/svg\" "
+  (void) FormatLocaleFile(file,"<?xml version=\"1.0\"?>\n");
+  (void) FormatLocaleFile(file,"<svg xmlns=\"http://www.w3.org/2000/svg\" "
     "xlink=\"http://www.w3.org/1999/xlink\" "
     "ev=\"http://www.w3.org/2001/xml-events\" version=\"1.1\" "
     "baseProfile=\"full\" width=\"%g\" height=\"%g\">\n",bounds.x2-bounds.x1,
@@ -635,16 +635,16 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
   for (i=0; i < (ssize_t) number_blocks; i++)
   {
     offset=blocks[i].offset;
-    (void) fprintf(file,"  <path stroke=\"#%02x%02x%02x\" fill=\"none\" "
-      "d=\"M %g %g",blocks[i].color->red,blocks[i].color->green,
+    (void) FormatLocaleFile(file,"  <path stroke=\"#%02x%02x%02x\" "
+      "fill=\"none\" d=\"M %g %g",blocks[i].color->red,blocks[i].color->green,
       blocks[i].color->blue,stitches[offset].x-bounds.x1,
       stitches[offset].y-bounds.y1);
     for (j=1; j < (ssize_t) (blocks[i+1].offset-offset); j++)
-      (void) fprintf(file," L %g %g",stitches[offset+j].x-bounds.x1,
+      (void) FormatLocaleFile(file," L %g %g",stitches[offset+j].x-bounds.x1,
         stitches[offset+j].y-bounds.y1);
-    (void) fprintf(file,"\"/>\n");
+    (void) FormatLocaleFile(file,"\"/>\n");
   }
-  (void) fprintf(file,"</svg>\n");
+  (void) FormatLocaleFile(file,"</svg>\n");
   (void) fclose(file);
   (void) CloseBlob(image);
   image=DestroyImage(image);
@@ -653,7 +653,7 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   read_info=CloneImageInfo(image_info);
   SetImageInfoBlob(read_info,(void *) NULL,0);
-  (void) FormatMagickString(read_info->filename,MaxTextExtent,"svg:%.1024s",
+  (void) FormatLocaleString(read_info->filename,MaxTextExtent,"svg:%s",
     filename);
   image=ReadImage(read_info,exception);
   if (image != (Image *) NULL)