#include "MagickCore/threshold.h"
#include "MagickCore/utility.h"
\f
+/*
+ Global declarations.
+*/
+static SplayTreeInfo
+ *xpm_symbolic = (SplayTreeInfo *) NULL;
+\f
/*
Forward declarations.
*/
p=source;
while (length-- && (*p != '\0'))
+ {
+ if (*p == '"')
+ break;
*destination++=(*p++);
+ }
if (length != 0)
*destination='\0';
return((ssize_t) (p-source));
next=NextXPMLine(xpm_buffer);
for (j=0; (j < (ssize_t) image->colors) && (next != (char *) NULL); j++)
{
+ char
+ symbolic[MagickPathExtent];
+
p=next;
next=NextXPMLine(p);
if (next == (char *) NULL)
q=(char *) NULL;
if (strlen(p) > width)
q=ParseXPMColor(p+width,MagickTrue);
+ *symbolic='\0';
if (q != (char *) NULL)
{
while ((isspace((int) ((unsigned char) *q)) == 0) && (*q != '\0'))
(void) CopyXPMColor(target,q,MagickMin((size_t) (next-q),
MagickPathExtent-1));
q=ParseXPMColor(target,MagickFalse);
+ (void) CopyXPMColor(symbolic,q,MagickMin((size_t) (next-q),
+ MagickPathExtent-1));
if (q != (char *) NULL)
*q='\0';
}
StripString(target);
+ if (*symbolic != '\0')
+ (void) AddValueToSplayTree(xpm_symbolic,ConstantString(target),
+ ConstantString(symbolic));
grey=strstr(target,"grey");
if (grey != (char *) NULL)
grey[2]='a';
MagickInfo
*entry;
+ if (xpm_symbolic == (SplayTreeInfo *) NULL)
+ xpm_symbolic=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
+ RelinquishMagickMemory);
entry=AcquireMagickInfo("XPM","PICON","Personal Icon");
entry->decoder=(DecodeImageHandler *) ReadXPMImage;
entry->encoder=(EncodeImageHandler *) WritePICONImage;
(void) UnregisterMagickInfo("PICON");
(void) UnregisterMagickInfo("PM");
(void) UnregisterMagickInfo("XPM");
+ if (xpm_symbolic != (SplayTreeInfo *) NULL)
+ xpm_symbolic=DestroySplayTree(xpm_symbolic);
}
\f
/*
picon->colormap,(size_t) colors,sizeof(*picon->colormap));
if (picon->colormap == (PixelInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationError");
- picon->colormap[colors-1].red=0;
- picon->colormap[colors-1].green=0;
- picon->colormap[colors-1].blue=0;
+ picon->colormap[colors-1].red=0.0;
+ picon->colormap[colors-1].green=0.0;
+ picon->colormap[colors-1].blue=0.0;
picon->colormap[colors-1].alpha=TransparentAlpha;
for (y=0; y < (ssize_t) picon->rows; y++)
{
GetPixelInfo(image,&pixel);
for (i=0; i < (ssize_t) image->colors; i++)
{
+ const char
+ *symbolic;
+
/*
Define XPM color.
*/
symbol[j]=Cixel[k];
}
symbol[j]='\0';
- (void) FormatLocaleString(buffer,MagickPathExtent,
- "\"%.1024s c %.1024s\",\n",symbol,name);
+ symbolic=GetValueFromSplayTree(xpm_symbolic,name);
+ if (symbolic == (const char *) NULL)
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "\"%.1024s c %.1024s\",\n",symbol,name);
+ else
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "\"%.1024s c %.1024s %.1024s\",\n",symbol,name,symbolic);
(void) WriteBlobString(image,buffer);
}
/*