image->intensity=(PixelIntensityMethod) intensity;
break;
}
- if ((LocaleNCompare(keyword,"profile:",8) == 0) ||
- (LocaleNCompare(keyword,"profile-",8) == 0))
+ if (LocaleCompare(keyword,"profile") == 0)
{
- size_t
- length;
-
- StringInfo
- *profile;
-
- length=(size_t) StringToLong(options);
- if ((MagickSizeType) length > GetBlobSize(image))
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,
- RelinquishMagickMemory);
- options=DestroyString(options);
- ThrowReaderException(CorruptImageError,
- "InsufficientImageDataInFile");
- }
if (profiles == (LinkedListInfo *) NULL)
profiles=NewLinkedList(0);
(void) AppendValueToLinkedList(profiles,
- AcquireString(keyword+8));
- profile=BlobToStringInfo((const void *) NULL,length);
- if (profile == (StringInfo *) NULL)
- {
- options=DestroyString(options);
- profiles=DestroyLinkedList(profiles,
- RelinquishMagickMemory);
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
- }
- if (EOFBlob(image) == MagickFalse)
- (void) SetImageProfile(image,keyword+8,profile,
- exception);
- profile=DestroyStringInfo(profile);
+ AcquireString(options));
break;
}
- if (LocaleCompare(keyword,"profile") == 0)
- break;
(void) SetImageProperty(image,keyword,options,exception);
break;
}
const char
*name;
- const StringInfo
+ StringInfo
*profile;
/*
name=(const char *) GetNextValueInLinkedList(profiles);
while (name != (const char *) NULL)
{
- profile=GetImageProfile(image,name);
- if (profile != (StringInfo *) NULL)
+ length=ReadBlobMSBLong(image);
+ profile=AcquireStringInfo(length);
+ if (profile == (StringInfo *) NULL)
+ break;
+ count=ReadBlob(image,length,GetStringInfoDatum(profile));
+ if (count != (ssize_t) length)
{
- register unsigned char
- *p;
-
- p=GetStringInfoDatum(profile);
- count=ReadBlob(image,GetStringInfoLength(profile),p);
- (void) count;
+ profile=DestroyStringInfo(profile);
+ break;
}
+ status=SetImageProfile(image,name,profile,exception);
+ profile=DestroyStringInfo(profile);
+ if (status == MagickFalse)
+ break;
name=(const char *) GetNextValueInLinkedList(profiles);
}
profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
*profile;
/*
- Write image profiles.
+ Write image profile names.
*/
ResetImageProfileIterator(image);
- name=GetNextImageProfile(image);
- while (name != (const char *) NULL)
+ for (name=GetNextImageProfile(image); name != (const char *) NULL; )
{
profile=GetImageProfile(image,name);
if (profile != (StringInfo *) NULL)
{
- (void) FormatLocaleString(buffer,MagickPathExtent,
- "profile:%s=%.20g\n",name,(double)
- GetStringInfoLength(profile));
+ (void) FormatLocaleString(buffer,MagickPathExtent,"profile=%s\n",
+ name);
(void) WriteBlobString(image,buffer);
}
name=GetNextImageProfile(image);
image->directory);
(void) WriteBlobByte(image,'\0');
}
- if (image->profiles != (void *) NULL)
+ if (image->profiles != 0)
{
const char
*name;
*profile;
/*
- Generic profile.
+ Write image profile blob.
*/
ResetImageProfileIterator(image);
name=GetNextImageProfile(image);
while (name != (const char *) NULL)
{
profile=GetImageProfile(image,name);
+ (void) WriteBlobMSBLong(image,(unsigned int)
+ GetStringInfoLength(profile));
(void) WriteBlob(image,GetStringInfoLength(profile),
GetStringInfoDatum(profile));
name=GetNextImageProfile(image);
image->intensity=(PixelIntensityMethod) intensity;
break;
}
- if ((LocaleNCompare(keyword,"profile:",8) == 0) ||
- (LocaleNCompare(keyword,"profile-",8) == 0))
+ if (LocaleCompare(keyword,"profile") == 0)
{
- size_t
- length;
-
- StringInfo
- *profile;
-
- length=StringToLong(options);
- if ((MagickSizeType) length > GetBlobSize(image))
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,
- RelinquishMagickMemory);
- options=DestroyString(options);
- ThrowReaderException(CorruptImageError,
- "InsufficientImageDataInFile");
- }
if (profiles == (LinkedListInfo *) NULL)
profiles=NewLinkedList(0);
(void) AppendValueToLinkedList(profiles,
- AcquireString(keyword+8));
- profile=BlobToStringInfo((const void *) NULL,length);
- if (profile == (StringInfo *) NULL)
- {
- options=DestroyString(options);
- profiles=DestroyLinkedList(profiles,
- RelinquishMagickMemory);
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
- }
- if (EOFBlob(image) == MagickFalse)
- (void) SetImageProfile(image,keyword+8,profile,
- exception);
- profile=DestroyStringInfo(profile);
+ AcquireString(options));
break;
}
- if (LocaleCompare(keyword,"profile") == 0)
- break;
(void) SetImageProperty(image,keyword,options,exception);
break;
}
*p++=(char) c;
} while (c != (int) '\0');
}
- if (profiles != (LinkedListInfo *) NULL)
+ if (profiles != (LinkedListInfo *) NULL)
{
const char
*name;
- const StringInfo
+ StringInfo
*profile;
- register unsigned char
- *p;
-
/*
- Read image profiles.
+ Read image profile blobs.
*/
ResetLinkedListIterator(profiles);
name=(const char *) GetNextValueInLinkedList(profiles);
while (name != (const char *) NULL)
{
- profile=GetImageProfile(image,name);
- if (profile != (StringInfo *) NULL)
+ length=ReadBlobMSBLong(image);
+ profile=AcquireStringInfo(length);
+ if (profile == (StringInfo *) NULL)
+ break;
+ count=ReadBlob(image,length,GetStringInfoDatum(profile));
+ if (count != (ssize_t) length)
{
- p=GetStringInfoDatum(profile);
- count=ReadBlob(image,GetStringInfoLength(profile),p);
+ profile=DestroyStringInfo(profile);
+ break;
}
+ status=SetImageProfile(image,name,profile,exception);
+ profile=DestroyStringInfo(profile);
+ if (status == MagickFalse)
+ break;
name=(const char *) GetNextValueInLinkedList(profiles);
}
profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
Create image colormap.
*/
packet_size=(size_t) (3UL*depth/8UL);
- if ((packet_size*image->colors) > GetBlobSize(image))
+ if ((MagickSizeType) (packet_size*image->colors) > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
image->colormap=(PixelInfo *) AcquireQuantumMemory(image->colors+1,
sizeof(*image->colormap));
for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushCharPixel(p,&pixel);
- image->colormap[i].red=ScaleCharToQuantum(pixel);
+ image->colormap[i].red=(MagickRealType)
+ ScaleCharToQuantum(pixel);
p=PushCharPixel(p,&pixel);
- image->colormap[i].green=ScaleCharToQuantum(pixel);
+ image->colormap[i].green=(MagickRealType)
+ ScaleCharToQuantum(pixel);
p=PushCharPixel(p,&pixel);
- image->colormap[i].blue=ScaleCharToQuantum(pixel);
+ image->colormap[i].blue=(MagickRealType)
+ ScaleCharToQuantum(pixel);
}
break;
}
for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushShortPixel(MSBEndian,p,&pixel);
- image->colormap[i].red=ScaleShortToQuantum(pixel);
+ image->colormap[i].red=(MagickRealType)
+ ScaleShortToQuantum(pixel);
p=PushShortPixel(MSBEndian,p,&pixel);
- image->colormap[i].green=ScaleShortToQuantum(pixel);
+ image->colormap[i].green=(MagickRealType)
+ ScaleShortToQuantum(pixel);
p=PushShortPixel(MSBEndian,p,&pixel);
- image->colormap[i].blue=ScaleShortToQuantum(pixel);
+ image->colormap[i].blue=(MagickRealType)
+ ScaleShortToQuantum(pixel);
}
break;
}
for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushLongPixel(MSBEndian,p,&pixel);
- image->colormap[i].red=ScaleLongToQuantum(pixel);
+ image->colormap[i].red=(MagickRealType)
+ ScaleLongToQuantum(pixel);
p=PushLongPixel(MSBEndian,p,&pixel);
- image->colormap[i].green=ScaleLongToQuantum(pixel);
+ image->colormap[i].green=(MagickRealType)
+ ScaleLongToQuantum(pixel);
p=PushLongPixel(MSBEndian,p,&pixel);
- image->colormap[i].blue=ScaleLongToQuantum(pixel);
+ image->colormap[i].blue=(MagickRealType)
+ ScaleLongToQuantum(pixel);
}
break;
}
*profile;
/*
- Generic profile.
+ Write image profile names.
*/
ResetImageProfileIterator(image);
for (name=GetNextImageProfile(image); name != (const char *) NULL; )
profile=GetImageProfile(image,name);
if (profile != (StringInfo *) NULL)
{
- (void) FormatLocaleString(buffer,MagickPathExtent,
- "profile:%s=%.20g\n",name,(double)
- GetStringInfoLength(profile));
+ (void) FormatLocaleString(buffer,MagickPathExtent,"profile=%s\n",
+ name);
(void) WriteBlobString(image,buffer);
}
name=GetNextImageProfile(image);
{
if (value[i] == (int) '}')
(void) WriteBlobByte(image,'\\');
- (void) WriteBlobByte(image,value[i]);
+ (void) WriteBlobByte(image,(unsigned char) value[i]);
}
(void) WriteBlobByte(image,'}');
}
*profile;
/*
- Write image profiles.
+ Write image profile blobs.
*/
ResetImageProfileIterator(image);
name=GetNextImageProfile(image);
while (name != (const char *) NULL)
{
profile=GetImageProfile(image,name);
+ (void) WriteBlobMSBLong(image,(unsigned int)
+ GetStringInfoLength(profile));
(void) WriteBlob(image,GetStringInfoLength(profile),
GetStringInfoDatum(profile));
name=GetNextImageProfile(image);
unsigned int
pixel;
- pixel=ScaleQuantumToLong(image->colormap[i].red);
+ pixel=ScaleQuantumToLong(ClampToQuantum(image->colormap[i].red));
q=PopLongPixel(MSBEndian,pixel,q);
- pixel=ScaleQuantumToLong(image->colormap[i].green);
+ pixel=ScaleQuantumToLong(ClampToQuantum(
+ image->colormap[i].green));
q=PopLongPixel(MSBEndian,pixel,q);
- pixel=ScaleQuantumToLong(image->colormap[i].blue);
+ pixel=ScaleQuantumToLong(ClampToQuantum(image->colormap[i].blue));
q=PopLongPixel(MSBEndian,pixel,q);
break;
}
unsigned short
pixel;
- pixel=ScaleQuantumToShort(image->colormap[i].red);
+ pixel=ScaleQuantumToShort(ClampToQuantum(image->colormap[i].red));
q=PopShortPixel(MSBEndian,pixel,q);
- pixel=ScaleQuantumToShort(image->colormap[i].green);
+ pixel=ScaleQuantumToShort(ClampToQuantum(
+ image->colormap[i].green));
q=PopShortPixel(MSBEndian,pixel,q);
- pixel=ScaleQuantumToShort(image->colormap[i].blue);
+ pixel=ScaleQuantumToShort(ClampToQuantum(
+ image->colormap[i].blue));
q=PopShortPixel(MSBEndian,pixel,q);
break;
}
unsigned char
pixel;
- pixel=(unsigned char) ScaleQuantumToChar(image->colormap[i].red);
+ pixel=(unsigned char) ScaleQuantumToChar(ClampToQuantum(
+ image->colormap[i].red));
q=PopCharPixel(pixel,q);
- pixel=(unsigned char) ScaleQuantumToChar(
- image->colormap[i].green);
+ pixel=(unsigned char) ScaleQuantumToChar(ClampToQuantum(
+ image->colormap[i].green));
q=PopCharPixel(pixel,q);
- pixel=(unsigned char) ScaleQuantumToChar(image->colormap[i].blue);
+ pixel=(unsigned char) ScaleQuantumToChar(ClampToQuantum(
+ image->colormap[i].blue));
q=PopCharPixel(pixel,q);
break;
}