% July 2001 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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/blob.h"
-#include "magick/blob-private.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/module.h"
-#include "magick/profile.h"
-#include "magick/splay-tree.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/string-private.h"
-#include "magick/token.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/profile.h"
+#include "MagickCore/splay-tree.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
+#include "MagickCore/token.h"
+#include "MagickCore/utility.h"
\f
/*
Forward declarations.
*/
static MagickBooleanType
- WriteMETAImage(const ImageInfo *,Image *);
+ WriteMETAImage(const ImageInfo *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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)
{
}
image->columns=1;
image->rows=1;
- if (SetImageBackgroundColor(image) == MagickFalse)
+ if (SetImageBackgroundColor(image,exception) == MagickFalse)
{
- InheritException(exception,&image->exception);
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read 8BIM binary metadata.
*/
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));
(void) WriteBlobByte(buff,(unsigned char) c);
}
}
- profile=AcquireStringInfo((size_t) GetBlobSize(buff));
- SetStringInfoDatum(profile,GetBlobStreamData(buff));
- status=SetImageProfile(image,"8bim",profile);
+ profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)
+ GetBlobSize(buff));
+ if (profile == (StringInfo *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ status=SetImageProfile(image,"8bim",profile,exception);
profile=DestroyStringInfo(profile);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
name[MaxTextExtent];
(void) FormatLocaleString(name,MaxTextExtent,"APP%d",1);
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));
ThrowReaderException(CoderError,"NoIPTCProfileAvailable");
}
profile=CloneStringInfo((StringInfo *) image_info->profile);
- iptc=AcquireImage((ImageInfo *) NULL);
+ iptc=AcquireImage((ImageInfo *) NULL,exception);
if (iptc == (Image *) NULL)
{
blob=DetachBlob(buff->blob);
}
#endif
}
- profile=AcquireStringInfo((size_t) GetBlobSize(buff));
- SetStringInfoDatum(profile,GetBlobStreamData(buff));
- status=SetImageProfile(image,name,profile);
+ profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)
+ GetBlobSize(buff));
+ if (profile == (StringInfo *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ status=SetImageProfile(image,name,profile,exception);
profile=DestroyStringInfo(profile);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((LocaleCompare(image_info->magick,"ICC") == 0) ||
(LocaleCompare(image_info->magick,"ICM") == 0))
{
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));
break;
(void) WriteBlobByte(buff,(unsigned char) c);
}
- profile=AcquireStringInfo((size_t) GetBlobSize(buff));
- SetStringInfoDatum(profile,GetBlobStreamData(buff));
- (void) SetImageProfile(image,"icc",profile);
+ profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)
+ GetBlobSize(buff));
+ if (profile == (StringInfo *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ (void) SetImageProfile(image,"icc",profile,exception);
profile=DestroyStringInfo(profile);
blob=DetachBlob(buff->blob);
blob=(unsigned char *) RelinquishMagickMemory(blob);
register unsigned char
*p;
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));
(void) WriteBlobByte(buff,(unsigned char) c);
}
}
- profile=AcquireStringInfo((size_t) GetBlobSize(buff));
+ profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)
+ GetBlobSize(buff));
+ if (profile == (StringInfo *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
subtract off the length of the 8BIM stuff.
*/
p[10]=(unsigned char) (length >> 8);
p[11]=(unsigned char) (length & 0xff);
SetStringInfoDatum(profile,GetBlobStreamData(buff));
- (void) SetImageProfile(image,"8bim",profile);
+ (void) SetImageProfile(image,"8bim",profile,exception);
profile=DestroyStringInfo(profile);
blob=DetachBlob(buff->blob);
blob=(unsigned char *) RelinquishMagickMemory(blob);
}
if (LocaleCompare(image_info->magick,"XMP") == 0)
{
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));
break;
(void) WriteBlobByte(buff,(unsigned char) c);
}
- profile=AcquireStringInfo((size_t) GetBlobSize(buff));
- SetStringInfoDatum(profile,GetBlobStreamData(buff));
- (void) SetImageProfile(image,"xmp",profile);
+ profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)
+ GetBlobSize(buff));
+ if (profile == (StringInfo *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ (void) SetImageProfile(image,"xmp",profile,exception);
profile=DestroyStringInfo(profile);
blob=DetachBlob(buff->blob);
blob=(unsigned char *) RelinquishMagickMemory(blob);
% The format of the WriteMETAImage method is:
%
% MagickBooleanType WriteMETAImage(const ImageInfo *image_info,
-% Image *image)
+% Image *image,ExceptionInfo *exception)
%
% Compression code contributed by Kyle Shorter.
%
%
% o image: A pointer to a Image structure.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static size_t GetIPTCStream(unsigned char **info,size_t length)
extent,
info_length;
- unsigned char
- buffer[4] = { '\0', '\0', '\0', '\0' };
-
unsigned int
marker;
info_length++;
if ((c & 0x80) != 0)
{
+ /*
+ Long format.
+ */
+ tag_length=0;
for (i=0; i < 4; i++)
{
- buffer[i]=(*p++);
+ tag_length<<=8;
+ tag_length|=(*p++);
length--;
if (length == 0)
break;
info_length++;
}
- tag_length=(((size_t) buffer[0]) << 24) |
- (((size_t) buffer[1]) << 16) |
- (((size_t) buffer[2]) << 8) | (((size_t) buffer[3]));
}
else
{
- tag_length=(size_t) (c << 8);
+ /*
+ Short format.
+ */
+ tag_length=((long) c) << 8;
c=(*p++);
length--;
if (length == 0)
break;
info_length++;
- tag_length|=c;
+ tag_length|=(long) c;
}
if (tag_length > (length+1))
break;
}
static MagickBooleanType WriteMETAImage(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
const StringInfo
*profile;
profile=GetImageProfile(image,"8bim");
if (profile == (StringInfo *) NULL)
ThrowWriterException(CoderError,"No8BIMDataIsAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) WriteBlob(image,GetStringInfoLength(profile),
profile=GetImageProfile(image,"8bim");
if (profile == (StringInfo *) NULL)
ThrowWriterException(CoderError,"No8BIMDataIsAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
info=GetStringInfoDatum(profile);
length=GetStringInfoLength(profile);
length=GetIPTCStream(&info,length);
profile=GetImageProfile(image,"8bim");
if (profile == (StringInfo *) NULL)
ThrowWriterException(CoderError,"No8BIMDataIsAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
AttachBlob(buff->blob,GetStringInfoDatum(profile),
length=GetIPTCStream(&info,length);
if (length == 0)
ThrowWriterException(CoderError,"NoIPTCProfileAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- buff=AcquireImage((ImageInfo *) NULL);
+ buff=AcquireImage((ImageInfo *) NULL,exception);
if (buff == (Image *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
AttachBlob(buff->blob,info,length);
profile=GetImageProfile(image,image_info->magick);
if (profile == (StringInfo *) NULL)
ThrowWriterException(CoderError,"NoAPP1DataIsAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) WriteBlob(image,GetStringInfoLength(profile),
profile=GetImageProfile(image,"icc");
if (profile == (StringInfo *) NULL)
ThrowWriterException(CoderError,"NoColorProfileIsAvailable");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) WriteBlob(image,GetStringInfoLength(profile),