]> granicus.if.org Git - imagemagick/blobdiff - coders/xbm.c
...
[imagemagick] / coders / xbm.c
index 3b3b314ddb430a2a0eeec0f88227908fb2436d16..ab887c4c523b2019204232ae450ac4ab8a609b88 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2017 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  %
@@ -171,8 +171,8 @@ static unsigned int XBMInteger(Image *image,short int *hex_digits)
 static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   char
-    buffer[MaxTextExtent],
-    name[MaxTextExtent];
+    buffer[MagickPathExtent],
+    name[MagickPathExtent];
 
   Image
     *image;
@@ -214,12 +214,12 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Open image file.
   */
   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);
   image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
@@ -233,12 +233,12 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   width=0;
   height=0;
   while (ReadBlobString(image,buffer) != (char *) NULL)
-    if (sscanf(buffer,"#define %s %u",name,&width) == 2)
+    if (sscanf(buffer,"#define %32s %u",name,&width) == 2)
       if ((strlen(name) >= 6) &&
           (LocaleCompare(name+strlen(name)-6,"_width") == 0))
         break;
   while (ReadBlobString(image,buffer) != (char *) NULL)
-    if (sscanf(buffer,"#define %s %u",name,&height) == 2)
+    if (sscanf(buffer,"#define %32s %u",name,&height) == 2)
       if ((strlen(name) >= 7) &&
           (LocaleCompare(name+strlen(name)-7,"_height") == 0))
         break;
@@ -253,13 +253,13 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   version=11;
   while (ReadBlobString(image,buffer) != (char *) NULL)
   {
-    if (sscanf(buffer,"static short %s = {",name) == 1)
+    if (sscanf(buffer,"static short %32s = {",name) == 1)
       version=10;
     else
-      if (sscanf(buffer,"static unsigned char %s = {",name) == 1)
+      if (sscanf(buffer,"static unsigned char %32s = {",name) == 1)
         version=11;
       else
-        if (sscanf(buffer,"static char %s = {",name) == 1)
+        if (sscanf(buffer,"static char %32s = {",name) == 1)
           version=11;
         else
           continue;
@@ -418,14 +418,12 @@ ModuleExport size_t RegisterXBMImage(void)
   MagickInfo
     *entry;
 
-  entry=SetMagickInfo("XBM");
+  entry=AcquireMagickInfo("XBM","XBM",
+    "X Windows system bitmap (black and white)");
   entry->decoder=(DecodeImageHandler *) ReadXBMImage;
   entry->encoder=(EncodeImageHandler *) WriteXBMImage;
   entry->magick=(IsImageFormatHandler *) IsXBM;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString(
-    "X Windows system bitmap (black and white)");
-  entry->module=ConstantString("XBM");
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }
@@ -485,8 +483,8 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
   ExceptionInfo *exception)
 {
   char
-    basename[MaxTextExtent],
-    buffer[MaxTextExtent];
+    basename[MagickPathExtent],
+    buffer[MagickPathExtent];
 
   MagickBooleanType
     status;
@@ -509,13 +507,13 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
     Open output image file.
   */
   assert(image_info != (const ImageInfo *) NULL);
-  assert(image_info->signature == MagickSignature);
+  assert(image_info->signature == MagickCoreSignature);
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
   if (status == MagickFalse)
     return(status);
@@ -524,16 +522,16 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
     Write X bitmap header.
   */
   GetPathComponent(image->filename,BasePath,basename);
-  (void) FormatLocaleString(buffer,MaxTextExtent,"#define %s_width %.20g\n",
+  (void) FormatLocaleString(buffer,MagickPathExtent,"#define %s_width %.20g\n",
     basename,(double) image->columns);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
-  (void) FormatLocaleString(buffer,MaxTextExtent,"#define %s_height %.20g\n",
+  (void) FormatLocaleString(buffer,MagickPathExtent,"#define %s_height %.20g\n",
     basename,(double) image->rows);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
-  (void) FormatLocaleString(buffer,MaxTextExtent,
+  (void) FormatLocaleString(buffer,MagickPathExtent,
     "static char %s_bits[] = {\n",basename);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
-  (void) CopyMagickString(buffer," ",MaxTextExtent);
+  (void) CopyMagickString(buffer," ",MagickPathExtent);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
   /*
     Convert MIFF to X bitmap pixels.
@@ -544,7 +542,7 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
   count=0;
   x=0;
   y=0;
-  (void) CopyMagickString(buffer," ",MaxTextExtent);
+  (void) CopyMagickString(buffer," ",MagickPathExtent);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -562,13 +560,13 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
           /*
             Write a bitmap byte to the image file.
           */
-          (void) FormatLocaleString(buffer,MaxTextExtent,"0x%02X, ",
+          (void) FormatLocaleString(buffer,MagickPathExtent,"0x%02X, ",
             (unsigned int) (byte & 0xff));
           (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
           count++;
           if (count == 12)
             {
-              (void) CopyMagickString(buffer,"\n  ",MaxTextExtent);
+              (void) CopyMagickString(buffer,"\n  ",MagickPathExtent);
               (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
               count=0;
             };
@@ -583,13 +581,13 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
           Write a bitmap byte to the image file.
         */
         byte>>=(8-bit);
-        (void) FormatLocaleString(buffer,MaxTextExtent,"0x%02X, ",
+        (void) FormatLocaleString(buffer,MagickPathExtent,"0x%02X, ",
           (unsigned int) (byte & 0xff));
         (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
         count++;
         if (count == 12)
           {
-            (void) CopyMagickString(buffer,"\n  ",MaxTextExtent);
+            (void) CopyMagickString(buffer,"\n  ",MagickPathExtent);
             (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
             count=0;
           };
@@ -601,7 +599,7 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
     if (status == MagickFalse)
       break;
   }
-  (void) CopyMagickString(buffer,"};\n",MaxTextExtent);
+  (void) CopyMagickString(buffer,"};\n",MagickPathExtent);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
   (void) CloseBlob(image);
   return(MagickTrue);