source_type,target_profile,target_type,intent,flags);
#define cmsOpenProfileFromMemTHR(context,profile,length) \
cmsOpenProfileFromMem(profile,length)
-#endif\r
-\r
-/*\r
- Forward declarations\r
-*/\r
-static MagickBooleanType\r
- SetImageProfileInternal(Image *,const char *,const StringInfo *,\r
- const MagickBooleanType,ExceptionInfo *);\r
-\r
-static void\r
+#endif
+
+/*
+ Forward declarations
+*/
+static MagickBooleanType
+ SetImageProfileInternal(Image *,const char *,const StringInfo *,
+ const MagickBooleanType,ExceptionInfo *);
+
+static void
WriteTo8BimProfile(Image *,const char*,const StringInfo *);
\f
/*
*quantum=(unsigned short) (*p++ << 8);
*quantum|=(unsigned short) (*p++ << 0);
return(p);
-}static inline void WriteResourceLong(unsigned char *p,\r
- const unsigned int quantum)\r
-{\r
- unsigned char\r
- buffer[4];\r
-\r
- buffer[0]=(unsigned char) (quantum >> 24);\r
- buffer[1]=(unsigned char) (quantum >> 16);\r
- buffer[2]=(unsigned char) (quantum >> 8);\r
- buffer[3]=(unsigned char) quantum;\r
- (void) CopyMagickMemory(p,buffer,4);\r
-}\r
-\r
-static void WriteTo8BimProfile(Image *image,const char *name,\r
- const StringInfo *iptc_profile)\r
-{\r
-\r
- const unsigned char\r
- *datum,\r
- *s;\r
-\r
- register const unsigned char\r
- *p;\r
-\r
- size_t\r
- length;\r
-\r
- StringInfo\r
- *profile;\r
-\r
- ssize_t\r
- count;\r
-\r
- unsigned char\r
- length_byte;\r
-\r
- unsigned int\r
- value;\r
-\r
- unsigned short\r
- id;\r
-\r
- if (LocaleCompare(name,"iptc") != 0)\r
- return;\r
- profile=(StringInfo *)GetValueFromSplayTree((SplayTreeInfo *)image->profiles,\r
- "8bim");\r
- if (profile == (StringInfo *) NULL)\r
- return;\r
- datum=GetStringInfoDatum(profile);\r
- length=GetStringInfoLength(profile);\r
- for (p=datum; p < (datum+length-16); )\r
- {\r
- s=p;\r
- if (LocaleNCompare((char *) p,"8BIM",4) != 0)\r
- break;\r
- p+=4;\r
- p=ReadResourceShort(p,&id);\r
- p=ReadResourceByte(p,&length_byte);\r
- p+=length_byte;\r
- if (((length_byte+1) & 0x01) != 0)\r
- p++;\r
- if (p > (datum+length-4))\r
- break;\r
- p=ReadResourceLong(p,&value);\r
- count=(ssize_t) value;\r
- if ((p > (datum+length-count)) || (count > length))\r
- break;\r
- if ((count & 0x01) != 0)\r
- count++;\r
- if (id == 0x0404)\r
- {\r
- size_t\r
- offset,\r
- rest;\r
-\r
- ssize_t\r
- new_count;\r
-\r
- StringInfo\r
- *new_profile;\r
-\r
- new_count=0;\r
- rest=(datum+length)-(p+count);\r
- if (iptc_profile == (StringInfo *) NULL)\r
- {\r
- offset=(s-datum);\r
- new_profile=AcquireStringInfo(offset+rest);\r
- (void) CopyMagickMemory(new_profile->datum,datum,offset);\r
- }\r
- else\r
- {\r
- offset=(p-datum);\r
- new_count=iptc_profile->length;\r
- if ((new_count & 0x01) != 0)\r
- new_count++;\r
- new_profile=AcquireStringInfo(offset+new_count+rest);\r
- (void) CopyMagickMemory(new_profile->datum,datum,offset-4);\r
- WriteResourceLong(new_profile->datum+offset-4,\r
- iptc_profile->length);\r
- (void) CopyMagickMemory(new_profile->datum+offset,\r
- iptc_profile->datum,iptc_profile->length);\r
- }\r
- (void) CopyMagickMemory(new_profile->datum+offset+new_count,p+count,\r
- rest);\r
- (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles,\r
- ConstantString("8bim"),CloneStringInfo(new_profile));\r
- new_profile=DestroyStringInfo(new_profile);\r
- break;\r
- }\r
- else\r
- p+=count;\r
- }\r
-}\r
-\r
+}static inline void WriteResourceLong(unsigned char *p,
+ const unsigned int quantum)
+{
+ unsigned char
+ buffer[4];
+
+ buffer[0]=(unsigned char) (quantum >> 24);
+ buffer[1]=(unsigned char) (quantum >> 16);
+ buffer[2]=(unsigned char) (quantum >> 8);
+ buffer[3]=(unsigned char) quantum;
+ (void) CopyMagickMemory(p,buffer,4);
+}
+
+static void WriteTo8BimProfile(Image *image,const char *name,
+ const StringInfo *iptc_profile)
+{
+
+ const unsigned char
+ *datum,
+ *s;
+
+ register const unsigned char
+ *p;
+
+ size_t
+ length;
+
+ StringInfo
+ *profile;
+
+ ssize_t
+ count;
+
+ unsigned char
+ length_byte;
+
+ unsigned int
+ value;
+
+ unsigned short
+ id;
+
+ if (LocaleCompare(name,"iptc") != 0)
+ return;
+ profile=(StringInfo *)GetValueFromSplayTree((SplayTreeInfo *)image->profiles,
+ "8bim");
+ if (profile == (StringInfo *) NULL)
+ return;
+ datum=GetStringInfoDatum(profile);
+ length=GetStringInfoLength(profile);
+ for (p=datum; p < (datum+length-16); )
+ {
+ s=p;
+ if (LocaleNCompare((char *) p,"8BIM",4) != 0)
+ break;
+ p+=4;
+ p=ReadResourceShort(p,&id);
+ p=ReadResourceByte(p,&length_byte);
+ p+=length_byte;
+ if (((length_byte+1) & 0x01) != 0)
+ p++;
+ if (p > (datum+length-4))
+ break;
+ p=ReadResourceLong(p,&value);
+ count=(ssize_t) value;
+ if ((p > (datum+length-count)) || (count > length))
+ break;
+ if ((count & 0x01) != 0)
+ count++;
+ if (id == 0x0404)
+ {
+ size_t
+ offset,
+ rest;
+
+ ssize_t
+ new_count;
+
+ StringInfo
+ *new_profile;
+
+ new_count=0;
+ rest=(datum+length)-(p+count);
+ if (iptc_profile == (StringInfo *) NULL)
+ {
+ offset=(s-datum);
+ new_profile=AcquireStringInfo(offset+rest);
+ (void) CopyMagickMemory(new_profile->datum,datum,offset);
+ }
+ else
+ {
+ offset=(p-datum);
+ new_count=iptc_profile->length;
+ if ((new_count & 0x01) != 0)
+ new_count++;
+ new_profile=AcquireStringInfo(offset+new_count+rest);
+ (void) CopyMagickMemory(new_profile->datum,datum,offset-4);
+ WriteResourceLong(new_profile->datum+offset-4,
+ iptc_profile->length);
+ (void) CopyMagickMemory(new_profile->datum+offset,
+ iptc_profile->datum,iptc_profile->length);
+ }
+ (void) CopyMagickMemory(new_profile->datum+offset+new_count,p+count,
+ rest);
+ (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles,
+ ConstantString("8bim"),CloneStringInfo(new_profile));
+ new_profile=DestroyStringInfo(new_profile);
+ break;
+ }
+ else
+ p+=count;
+ }
+}
+
static void GetProfilesFromResourceBlock(Image *image,
const StringInfo *resource_block,ExceptionInfo *exception)
{
{
if (LocaleCompare(name,"8bim") == 0)
GetProfilesFromResourceBlock(image,profile,exception);
- else if (recursive == MagickFalse)\r
+ else if (recursive == MagickFalse)
WriteTo8BimProfile(image,name,profile);
}
/*