]> granicus.if.org Git - imagemagick/blobdiff - coders/xpm.c
(no commit message)
[imagemagick] / coders / xpm.c
index a3bc383991d5f77ba97239c0dddb9f239fb3a8ba..ba657c214efc7013e12e42cc7b152b1ac046c556 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 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  %
@@ -139,11 +139,11 @@ static MagickBooleanType IsXPM(const unsigned char *magick,const size_t length)
 */
 
 static int CompareXPMColor(const void *target,const void *source)
-{ 
+{
   const char
     *p,
     *q;
-  
   p=(const char *) target;
   q=(const char *) source;
   return(strcmp(p,q));
@@ -242,7 +242,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *indexes;
 
   register ssize_t
-    i,
     x;
 
   register PixelPacket
@@ -327,7 +326,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Remove unquoted characters.
   */
-  i=0;
   active=MagickFalse;
   q=xpm_buffer;
   while (*p != '\0')
@@ -352,7 +350,6 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read image colormap.
   */
-  i=1;
   next=NextXPMLine(xpm_buffer);
   for (j=0; (j < (ssize_t) image->colors) && (next != (char*) NULL); j++)
   {
@@ -384,7 +381,9 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         image->storage_class=DirectClass;
         image->matte=MagickTrue;
       }
-    if (QueryColorDatabase(target,&image->colormap[j],exception) == MagickFalse)
+    status=QueryColorCompliance(target,AllCompliance,&image->colormap[j],
+      exception);
+    if (status == MagickFalse)
       break;
   }
   if (j < (ssize_t) image->colors)
@@ -519,8 +518,7 @@ ModuleExport void UnregisterXPMImage(void)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Procedure WritePICONImage() writes an image to a file in the Personal Icon
-%  format.
+%  WritePICONImage() writes an image to a file in the Personal Icon format.
 %
 %  The format of the WritePICONImage method is:
 %
@@ -742,9 +740,9 @@ static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
     "static char *%s[] = {\n",basename);
   (void) WriteBlobString(image,buffer);
   (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
-  (void) FormatMagickString(buffer,MaxTextExtent,"\"%lu %lu %lu %lu\",\n",
-    (unsigned long) picon->columns,(unsigned long) picon->rows,(unsigned long)
-    colors,(unsigned long) characters_per_pixel);
+  (void) FormatMagickString(buffer,MaxTextExtent,
+    "\"%.20g %.20g %.20g %.20g\",\n",(double) picon->columns,(double)
+    picon->rows,(double) colors,(double) characters_per_pixel);
   (void) WriteBlobString(image,buffer);
   GetMagickPixelPacket(image,&pixel);
   for (i=0; i < (ssize_t) colors; i++)
@@ -827,7 +825,7 @@ static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Procedure WriteXPMImage() writes an image to a file in the X pixmap format.
+%  WriteXPMImage() writes an image to a file in the X pixmap format.
 %
 %  The format of the WriteXPMImage method is:
 %
@@ -839,7 +837,6 @@ static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
 %
 %    o image:  The image.
 %
-%
 */
 static MagickBooleanType WriteXPMImage(const ImageInfo *image_info,Image *image)
 {
@@ -968,16 +965,18 @@ static MagickBooleanType WriteXPMImage(const ImageInfo *image_info,Image *image)
       (void) FormatMagickString(buffer,MaxTextExtent,"xpm_%s",basename);
       (void) CopyMagickString(basename,buffer,MaxTextExtent);
     }
-  for (i=0; basename[i] != '\0'; i++)
-    if (isalpha((int) ((unsigned char) basename[i])) == 0)
+  if (isalpha((int) ((unsigned char) basename[0])) == 0)
+    basename[0]='_';
+  for (i=1; basename[i] != '\0'; i++)
+    if (isalnum((int) ((unsigned char) basename[i])) == 0)
       basename[i]='_';
   (void) FormatMagickString(buffer,MaxTextExtent,
     "static char *%s[] = {\n",basename);
   (void) WriteBlobString(image,buffer);
   (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
-  (void) FormatMagickString(buffer,MaxTextExtent,"\"%lu %lu %lu %lu\",\n",
-    (unsigned long) image->columns,(unsigned long) image->rows,(unsigned long)
-    image->colors,(unsigned long) characters_per_pixel);
+  (void) FormatMagickString(buffer,MaxTextExtent,
+    "\"%.20g %.20g %.20g %.20g \",\n",(double) image->columns,(double)
+    image->rows,(double) image->colors,(double) characters_per_pixel);
   (void) WriteBlobString(image,buffer);
   GetMagickPixelPacket(image,&pixel);
   for (i=0; i < (ssize_t) image->colors; i++)