// Little Color Management System
// Copyright (c) 1998-2011 Marti Maria Saguer
//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
-// The above copyright notice and this permission notice shall be included in
+// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//---------------------------------------------------------------------------------
#include "lcms2_internal.h"
-// Tag Serialization -----------------------------------------------------------------------------
+// Tag Serialization -----------------------------------------------------------------------------
// This file implements every single tag and tag type as described in the ICC spec. Some types
// have been deprecated, like ncl and Data. There is no implementation for those types as there
// are no profiles holding them. The programmer can also extend this list by defining his own types
// by using the appropiate plug-in. There are three types of plug ins regarding that. First type
// allows to define new tags using any existing type. Next plug-in type allows to define new types
// and the third one is very specific: allows to extend the number of elements in the multiprofile
-// elements special type.
+// elements special type.
//--------------------------------------------------------------------------------------------------
// Some broken types
return TRUE;
}
- pt = Anterior = LinkedList;
+ pt = Anterior = LinkedList;
while (pt != NULL) {
if (Plugin->Handler.Signature == pt -> Handler.Signature) {
- pt ->Handler = Plugin ->Handler; // Replace old behaviour.
+ pt ->Handler = Plugin ->Handler; // Replace old behaviour.
// Note that since no memory is allocated, unregister does not
- // reset this action.
+ // reset this action.
return TRUE;
- }
+ }
- Anterior = pt;
+ Anterior = pt;
pt = pt ->Next;
}
pt = (_cmsTagTypeLinkedList*) _cmsPluginMalloc(sizeof(_cmsTagTypeLinkedList));
if (pt == NULL) return FALSE;
- pt ->Handler = Plugin ->Handler;
+ pt ->Handler = Plugin ->Handler;
pt ->Next = NULL;
- if (Anterior)
+ if (Anterior)
Anterior -> Next = pt;
return TRUE;
{
_cmsTagTypeLinkedList* pt;
- for (pt = LinkedList;
+ for (pt = LinkedList;
pt != NULL;
pt = pt ->Next) {
cmsUInt32Number i;
_cmsAssert(io != NULL);
- _cmsAssert(Array != NULL);
+ _cmsAssert(!(Array == NULL && n > 0));
for (i=0; i < n; i++) {
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) Array[i])) return FALSE;
}
// To deal with position tables
-typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
+typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag);
// Helper function to deal with position tables as decribed in ICC spec 4.3
// A table of n elements is readed, where first comes n records containing offsets and sizes and
// then a block containing the data itself. This allows to reuse same data in more than one entry
static
-cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number Count,
- cmsUInt32Number BaseOffset,
+cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
+ cmsIOHANDLER* io,
+ cmsUInt32Number Count,
+ cmsUInt32Number BaseOffset,
void *Cargo,
PositionTableEntryFn ElementFn)
{
// Success
if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
- if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
+ if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
return TRUE;
-Error:
+Error:
if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
return FALSE;
// Same as anterior, but for write position tables
static
-cmsBool WritePositionTable(struct _cms_typehandler_struct* self,
+cmsBool WritePositionTable(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
cmsUInt32Number SizeOfTag,
- cmsUInt32Number Count,
- cmsUInt32Number BaseOffset,
+ cmsUInt32Number Count,
+ cmsUInt32Number BaseOffset,
void *Cargo,
PositionTableEntryFn ElementFn)
{
ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number *));
if (ElementSizes == NULL) goto Error;
-
+
// Keep starting position of curve offsets
DirectoryPos = io ->Tell(io);
// Write a fake directory to be filled latter on
for (i=0; i < Count; i++) {
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
+ if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // size
}
for (i=0; i < Count; i++) {
Before = io ->Tell(io);
- ElementOffsets[i] = Before - BaseOffset;
+ ElementOffsets[i] = Before - BaseOffset;
// Callback to write...
if (!ElementFn(self, io, Cargo, i, SizeOfTag)) goto Error;
// Now the size
- ElementSizes[i] = io ->Tell(io) - Before;
+ ElementSizes[i] = io ->Tell(io) - Before;
}
// Write the directory
if (!io ->Seek(io, DirectoryPos)) goto Error;
for (i=0; i < Count; i++) {
- if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
- if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
+ if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
+ if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
}
if (!io ->Seek(io, CurrentPos)) goto Error;
// ********************************************************************************
//The XYZType contains an array of three encoded values for the XYZ tristimulus
-//values. Tristimulus values must be non-negative. The signed encoding allows for
+//values. Tristimulus values must be non-negative. The signed encoding allows for
//implementation optimizations by minimizing the number of fixed formats.
// ********************************************************************************
// Type chromaticity. Only one value is allowed
// ********************************************************************************
-// The chromaticity tag type provides basic chromaticity data and type of
+// The chromaticity tag type provides basic chromaticity data and type of
// phosphors or colorants of a monitor to applications and utilities.
static
static
cmsBool SaveOneChromaticity(cmsFloat64Number x, cmsFloat64Number y, cmsIOHANDLER* io)
{
- if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(x))) return FALSE;
- if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(y))) return FALSE;
+ if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(x))) return FALSE;
+ if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(y))) return FALSE;
return TRUE;
}
return TRUE;
cmsUNUSED_PARAMETER(nItems);
- cmsUNUSED_PARAMETER(self);
+ cmsUNUSED_PARAMETER(self);
}
static
// Type cmsSigColorantOrderType
// ********************************************************************************
-// This is an optional tag which specifies the laydown order in which colorants will
-// be printed on an n-colorant device. The laydown order may be the same as the
-// channel generation order listed in the colorantTableTag or the channel order of a
-// colour space such as CMYK, in which case this tag is not needed. When this is not
-// the case (for example, ink-towers sometimes use the order KCMY), this tag may be
-// used to specify the laydown order of the colorants.
+// This is an optional tag which specifies the laydown order in which colorants will
+// be printed on an n-colorant device. The laydown order may be the same as the
+// channel generation order listed in the colorantTableTag or the channel order of a
+// colour space such as CMYK, in which case this tag is not needed. When this is not
+// the case (for example, ink-towers sometimes use the order KCMY), this tag may be
+// used to specify the laydown order of the colorants.
static
static
cmsBool Type_ColorantOrderType_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsUInt8Number* ColorantOrder = (cmsUInt8Number*) Ptr;
+ cmsUInt8Number* ColorantOrder = (cmsUInt8Number*) Ptr;
cmsUInt32Number i, sz, Count;
// Get the length
if (ColorantOrder[i] != 0xFF) Count++;
}
- if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
sz = Count * sizeof(cmsUInt8Number);
- if (!io -> Write(io, sz, ColorantOrder)) return FALSE;
+ if (!io -> Write(io, sz, ColorantOrder)) return FALSE;
return TRUE;
// ********************************************************************************
// Type cmsSigS15Fixed16ArrayType
// ********************************************************************************
-// This type represents an array of generic 4-byte/32-bit fixed point quantity.
+// This type represents an array of generic 4-byte/32-bit fixed point quantity.
// The number of values is determined from the size of the tag.
static
_cmsFree(self ->ContextID, array_double);
return NULL;
- }
+ }
}
*nItems = n;
for (i=0; i < nItems; i++) {
- if (!_cmsWrite15Fixed16Number(io, Value[i])) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, Value[i])) return FALSE;
}
return TRUE;
// ********************************************************************************
// Type cmsSigU16Fixed16ArrayType
// ********************************************************************************
-// This type represents an array of generic 4-byte/32-bit quantity.
+// This type represents an array of generic 4-byte/32-bit quantity.
// The number of values is determined from the size of the tag.
cmsUInt32Number v = (cmsUInt32Number) floor(Value[i]*65536.0 + 0.5);
- if (!_cmsWriteUInt32Number(io, v)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, v)) return FALSE;
}
return TRUE;
// Type cmsSigSignatureType
// ********************************************************************************
//
-// The signatureType contains a four-byte sequence, Sequences of less than four
-// characters are padded at the end with spaces, 20h.
-// Typically this type is used for registered tags that can be displayed on many
+// The signatureType contains a four-byte sequence, Sequences of less than four
+// characters are padded at the end with spaces, 20h.
+// Typically this type is used for registered tags that can be displayed on many
// development systems as a sequence of four characters.
static
static
cmsBool Type_Signature_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsSignature* SigPtr = (cmsSignature*) Ptr;
-
+ cmsSignature* SigPtr = (cmsSignature*) Ptr;
+
return _cmsWriteUInt32Number(io, *SigPtr);
cmsUNUSED_PARAMETER(nItems);
// Type cmsSigTextType
// ********************************************************************************
//
-// The textType is a simple text structure that contains a 7-bit ASCII text string.
-// The length of the string is obtained by subtracting 8 from the element size portion
+// The textType is a simple text structure that contains a 7-bit ASCII text string.
+// The length of the string is obtained by subtracting 8 from the element size portion
// of the tag itself. This string must be terminated with a 00h byte.
static
Text = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1);
if (Text == NULL) goto Error;
- if (io -> Read(io, Text, sizeof(char), SizeOfTag) != SizeOfTag) goto Error;
+ if (io -> Read(io, Text, sizeof(char), SizeOfTag) != SizeOfTag) goto Error;
// Make sure text is properly ended
Text[SizeOfTag] = 0;
*nItems = 1;
-
+
// Keep the result
if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
return (void*) mlu;
Error:
- if (mlu != NULL)
+ if (mlu != NULL)
cmsMLUfree(mlu);
if (Text != NULL)
_cmsFree(self ->ContextID, Text);
static
cmsBool Type_Text_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsMLU* mlu = (cmsMLU*) Ptr;
+ cmsMLU* mlu = (cmsMLU*) Ptr;
cmsUInt32Number size;
cmsBool rc;
char* Text;
-
+
// Get the size of the string. Note there is an extra "\0" at the end
size = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
if (size == 0) return FALSE; // Cannot be zero!
static
cmsTagTypeSignature DecideTextType(cmsFloat64Number ICCVersion, const void *Data)
{
- if (ICCVersion >= 4.0)
+ if (ICCVersion >= 4.0)
return cmsSigMultiLocalizedUnicodeType;
-
+
return cmsSigTextType;
-
+
cmsUNUSED_PARAMETER(Data);
}
cmsUInt32Number LenOfData;
*nItems = 0;
-
+
if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
LenOfData = SizeOfTag - sizeof(cmsUInt32Number);
}
if (io -> Read(io, BinData ->data, sizeof(cmsUInt8Number), LenOfData) != LenOfData) {
-
+
_cmsFree(self ->ContextID, BinData);
return NULL;
}
*nItems = 1;
-
+
return (void*) BinData;
}
cmsBool Type_Data_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsICCData* BinData = (cmsICCData*) Ptr;
-
+
if (!_cmsWriteUInt32Number(io, BinData ->flag)) return FALSE;
return io ->Write(io, BinData ->len, BinData ->data);
SizeOfTag -= sizeof(cmsUInt32Number);
// Check for size
- if (SizeOfTag < AsciiCount) return NULL;
+ if (SizeOfTag < AsciiCount) return NULL;
// All seems Ok, allocate the container
mlu = cmsMLUalloc(self ->ContextID, 1);
if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
_cmsFree(self ->ContextID, (void*) Text);
Text = NULL;
-
+
// Skip Unicode code
if (SizeOfTag < 2* sizeof(cmsUInt32Number)) goto Done;
- if (!_cmsReadUInt32Number(io, &UnicodeCode)) goto Done;
- if (!_cmsReadUInt32Number(io, &UnicodeCount)) goto Done;
+ if (!_cmsReadUInt32Number(io, &UnicodeCode)) goto Done;
+ if (!_cmsReadUInt32Number(io, &UnicodeCount)) goto Done;
SizeOfTag -= 2* sizeof(cmsUInt32Number);
if (SizeOfTag < UnicodeCount*sizeof(cmsUInt16Number)) goto Done;
SizeOfTag -= UnicodeCount*sizeof(cmsUInt16Number);
// Skip ScriptCode code if present. Some buggy profiles does have less
- // data that stricttly required. We need to skip it as this type may come
+ // data that stricttly required. We need to skip it as this type may come
// embedded in other types.
-
+
if (SizeOfTag >= sizeof(cmsUInt16Number) + sizeof(cmsUInt8Number) + 67) {
if (!_cmsReadUInt16Number(io, &ScriptCodeCode)) goto Done;
- if (!_cmsReadUInt8Number(io, &ScriptCodeCount)) goto Done;
+ if (!_cmsReadUInt8Number(io, &ScriptCodeCount)) goto Done;
// Skip rest of tag
for (i=0; i < 67; i++) {
// Used below for writting zeroes
memset(Filler, 0, sizeof(Filler));
-
+
// Get the len of string
len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
-
+
// From ICC3.4: It has been found that textDescriptionType can contain misaligned data
//(see clause 4.1 for the definition of \93aligned\94). Because the Unicode language
// code and Unicode count immediately follow the ASCII description, their
// alignment is not correct if the ASCII count is not a multiple of four. The
// ScriptCode code is misaligned when the ASCII count is odd. Profile reading and
// writing software must be written carefully in order to handle these alignment
- // problems.
+ // problems.
// Compute an aligned size
len_aligned = _cmsALIGNLONG(len);
Wide = (wchar_t*) _cmsCalloc(self ->ContextID, len, sizeof(wchar_t));
if (Wide == NULL) goto Error;
- // Get both representations.
+ // Get both representations.
cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text, len * sizeof(char));
cmsMLUgetWide(mlu, cmsNoLanguage, cmsNoCountry, Wide, len * sizeof(wchar_t));
}
-
+
// * cmsUInt32Number count; * Description length
// * cmsInt8Number desc[count] * NULL terminated ascii string
// * cmsUInt32Number ucLangCode; * UniCode language code
// * cmsUInt16Number scCode; * ScriptCode code
// * cmsUInt8Number scCount; * ScriptCode count
// * cmsInt8Number scDesc[67]; * ScriptCode Description
-
- if (!_cmsWriteUInt32Number(io, len_aligned)) goto Error;
- if (!io ->Write(io, len, Text)) goto Error;
- if (!io ->Write(io, len_filler_alignment, Filler)) goto Error;
+
+ if (!_cmsWriteUInt32Number(io, len_aligned)) goto Error;
+ if (!io ->Write(io, len, Text)) goto Error;
+ if (!io ->Write(io, len_filler_alignment, Filler)) goto Error;
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // ucLanguageCode
-
+
// This part is tricky: we need an aligned tag size, and the ScriptCode part
// takes 70 bytes, so we need 2 extra bytes to do the alignment
- if (!_cmsWriteUInt32Number(io, len_aligned+1)) goto Error;
+ if (!_cmsWriteUInt32Number(io, len_aligned+1)) goto Error;
// Note that in some compilers sizeof(cmsUInt16Number) != sizeof(wchar_t)
- if (!_cmsWriteWCharArray(io, len, Wide)) goto Error;
- if (!_cmsWriteUInt16Array(io, len_filler_alignment+1, (cmsUInt16Number*) Filler)) goto Error;
+ if (!_cmsWriteWCharArray(io, len, Wide)) goto Error;
+ if (!_cmsWriteUInt16Array(io, len_filler_alignment+1, (cmsUInt16Number*) Filler)) goto Error;
// ScriptCode Code & count (unused)
- if (!_cmsWriteUInt16Number(io, 0)) goto Error;
- if (!_cmsWriteUInt8Number(io, 0)) goto Error;
-
+ if (!_cmsWriteUInt16Number(io, 0)) goto Error;
+ if (!_cmsWriteUInt8Number(io, 0)) goto Error;
+
if (!io ->Write(io, 67, Filler)) goto Error;
rc = TRUE;
static
cmsTagTypeSignature DecideTextDescType(cmsFloat64Number ICCVersion, const void *Data)
{
- if (ICCVersion >= 4.0)
+ if (ICCVersion >= 4.0)
return cmsSigMultiLocalizedUnicodeType;
-
+
return cmsSigTextDescriptionType;
-
+
cmsUNUSED_PARAMETER(Data);
}
case 0: // Linear.
- NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, 2, Linear);
+ NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, 2, Linear);
if (!NewGamma) return NULL;
*nItems = 1;
return NewGamma;
default: // Curve
+ if (Count > 0x7FFF)
+ return NULL; // This is to prevent bad guys for doing bad things
+
NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count, NULL);
if (!NewGamma) return NULL;
- if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) return NULL;
+ if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) return NULL;
*nItems = 1;
return NewGamma;
// Single gamma, preserve number
cmsUInt16Number SingleGammaFixed = _cmsDoubleTo8Fixed8(Curve ->Segments[0].Params[0]);
- if (!_cmsWriteUInt32Number(io, 1)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 1)) return FALSE;
if (!_cmsWriteUInt16Number(io, SingleGammaFixed)) return FALSE;
return TRUE;
-
+
}
- if (!_cmsWriteUInt32Number(io, Curve ->nEntries)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, Curve ->nEntries)) return FALSE;
return _cmsWriteUInt16Array(io, Curve ->nEntries, Curve ->Table16);
cmsUNUSED_PARAMETER(nItems);
for (i=0; i < n; i++) {
- if (!_cmsRead15Fixed16Number(io, &Params[i])) return NULL;
+ if (!_cmsRead15Fixed16Number(io, &Params[i])) return NULL;
}
NewGamma = cmsBuildParametricToneCurve(self ->ContextID, Type+1, Params);
cmsUNUSED_PARAMETER(SizeOfTag);
}
-
+
static
cmsBool Type_ParametricCurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
int i, nParams, typen;
static const int ParamsByType[] = { 0, 1, 3, 4, 5, 7 };
-
+
typen = Curve -> Segments[0].Type;
if (Curve ->nSegments > 1 || typen < 1) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Multisegment or Inverted parametric curves cannot be written");
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Multisegment or Inverted parametric curves cannot be written");
return FALSE;
}
if (typen > 5) {
- cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported parametric curve");
- return FALSE;
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported parametric curve");
+ return FALSE;
}
nParams = ParamsByType[typen];
-
+
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) (Curve ->Segments[0].Type - 1))) return FALSE;
if (!_cmsWriteUInt16Number(io, 0)) return FALSE; // Reserved
for (i=0; i < nParams; i++) {
- if (!_cmsWrite15Fixed16Number(io, Curve -> Segments[0].Params[i])) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, Curve -> Segments[0].Params[i])) return FALSE;
}
-
+
return TRUE;
cmsUNUSED_PARAMETER(nItems);
// Type cmsSigDateTimeType
// ********************************************************************************
-// A 12-byte value representation of the time and date, where the byte usage is assigned
-// as specified in table 1. The actual values are encoded as 16-bit unsigned integers
+// A 12-byte value representation of the time and date, where the byte usage is assigned
+// as specified in table 1. The actual values are encoded as 16-bit unsigned integers
// (uInt16Number - see 5.1.6).
//
-// All the dateTimeNumber values in a profile shall be in Coordinated Universal Time
+// All the dateTimeNumber values in a profile shall be in Coordinated Universal Time
// (UTC, also known as GMT or ZULU Time). Profile writers are required to convert local
-// time to UTC when setting these values. Programmes that display these values may show
-// the dateTimeNumber as UTC, show the equivalent local time (at current locale), or
+// time to UTC when setting these values. Programmes that display these values may show
+// the dateTimeNumber as UTC, show the equivalent local time (at current locale), or
// display both UTC and local versions of the dateTimeNumber.
static
if (NewDateTime == NULL) return NULL;
if (io->Read(io, ×tamp, sizeof(cmsDateTimeNumber), 1) != 1) return NULL;
-
+
_cmsDecodeDateTimeNumber(×tamp, NewDateTime);
*nItems = 1;
/*
The measurementType information refers only to the internal profile data and is
-meant to provide profile makers an alternative to the default measurement
+meant to provide profile makers an alternative to the default measurement
specifications.
*/
cmsBool Type_Measurement_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsICCMeasurementConditions* mc =(cmsICCMeasurementConditions*) Ptr;
-
+
if (!_cmsWriteUInt32Number(io, mc->Observer)) return FALSE;
if (!_cmsWriteXYZNumber(io, &mc->Backing)) return FALSE;
if (!_cmsWriteUInt32Number(io, mc->Geometry)) return FALSE;
// Type cmsSigMultiLocalizedUnicodeType
// ********************************************************************************
//
-// Do NOT trust SizeOfTag as there is an issue on the definition of profileSequenceDescTag. See the TechNote from
+// Do NOT trust SizeOfTag as there is an issue on the definition of profileSequenceDescTag. See the TechNote from
// Max Derhak and Rohit Patil about this: basically the size of the string table should be guessed and cannot be
// taken from the size of tag if this tag is embedded as part of bigger structures (profileSequenceDescTag, for instance)
//
void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
cmsMLU* mlu;
- cmsUInt32Number Count, RecLen, NumOfWchar;
+ cmsUInt32Number Count, RecLen, NumOfWchar;
cmsUInt32Number SizeOfHeader;
cmsUInt32Number Len, Offset;
cmsUInt32Number i;
cmsUInt32Number BeginOfThisString, EndOfThisString, LargestPosition;
*nItems = 0;
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
- if (!_cmsReadUInt32Number(io, &RecLen)) return NULL;
+ if (!_cmsReadUInt32Number(io, &Count)) return NULL;
+ if (!_cmsReadUInt32Number(io, &RecLen)) return NULL;
if (RecLen != 12) {
for (i=0; i < Count; i++) {
- if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Language)) goto Error;
- if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Country)) goto Error;
+ if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Language)) goto Error;
+ if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Country)) goto Error;
// Now deal with Len and offset.
- if (!_cmsReadUInt32Number(io, &Len)) goto Error;
+ if (!_cmsReadUInt32Number(io, &Len)) goto Error;
if (!_cmsReadUInt32Number(io, &Offset)) goto Error;
// Check for overflow
// True begin of the string
BeginOfThisString = Offset - SizeOfHeader - 8;
-
+
// Ajust to wchar_t elements
- mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
+ mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
mlu ->Entries[i].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
// To guess maximum size, add offset + len
// Now read the remaining of tag and fill all strings. Substract the directory
SizeOfTag = (LargestPosition * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
+ if (SizeOfTag == 0)
+ {
+ Block = NULL;
+ NumOfWchar = 0;
- Block = (wchar_t*) _cmsMalloc(self ->ContextID, SizeOfTag);
- if (Block == NULL) goto Error;
-
- NumOfWchar = SizeOfTag / sizeof(wchar_t);
-
- if (!_cmsReadWCharArray(io, NumOfWchar, Block)) goto Error;
+ }
+ else
+ {
+ Block = (wchar_t*) _cmsMalloc(self ->ContextID, SizeOfTag);
+ if (Block == NULL) goto Error;
+ NumOfWchar = SizeOfTag / sizeof(wchar_t);
+ if (!_cmsReadWCharArray(io, NumOfWchar, Block)) goto Error;
+ }
mlu ->MemPool = Block;
mlu ->PoolSize = SizeOfTag;
*nItems = 1;
return (void*) mlu;
-Error:
+Error:
if (mlu) cmsMLUfree(mlu);
- return NULL;
+ return NULL;
}
static
if (Ptr == NULL) {
// Empty placeholder
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
return TRUE;
}
-
- if (!_cmsWriteUInt32Number(io, mlu ->UsedEntries)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
-
+
+ if (!_cmsWriteUInt32Number(io, mlu ->UsedEntries)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
+
HeaderSize = 12 * mlu ->UsedEntries + sizeof(_cmsTagBase);
for (i=0; i < mlu ->UsedEntries; i++) {
Len = mlu ->Entries[i].Len;
Offset = mlu ->Entries[i].StrW;
-
+
Len = (Len * sizeof(cmsUInt16Number)) / sizeof(wchar_t);
Offset = (Offset * sizeof(cmsUInt16Number)) / sizeof(wchar_t) + HeaderSize + 8;
- if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Language)) return FALSE;
- if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Country)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Language)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Country)) return FALSE;
if (!_cmsWriteUInt32Number(io, Len)) return FALSE;
- if (!_cmsWriteUInt32Number(io, Offset)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, Offset)) return FALSE;
}
if (!_cmsWriteWCharArray(io, mlu ->PoolUsed / sizeof(wchar_t), (wchar_t*) mlu ->MemPool)) return FALSE;
static
void Type_MLU_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsMLUfree((cmsMLU*) Ptr);
return;
}
/*
-This structure represents a colour transform using tables of 8-bit precision.
-This type contains four processing elements: a 3 by 3 matrix (which shall be
-the identity matrix unless the input colour space is XYZ), a set of one dimensional
-input tables, a multidimensional lookup table, and a set of one dimensional output
+This structure represents a colour transform using tables of 8-bit precision.
+This type contains four processing elements: a 3 by 3 matrix (which shall be
+the identity matrix unless the input colour space is XYZ), a set of one dimensional
+input tables, a multidimensional lookup table, and a set of one dimensional output
tables. Data is processed using these elements via the following sequence:
(matrix) -> (1d input tables) -> (multidimensional lookup table - CLUT) -> (1d output tables)
// Read 8 bit tables as gamma functions
-static
+static
cmsBool Read8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, int nChannels)
{
cmsStage* mpe;
if (nChannels > cmsMAXCHANNELS) return FALSE;
if (nChannels <= 0) return FALSE;
-
+
memset(Tables, 0, sizeof(Tables));
Temp = (cmsUInt8Number*) _cmsMalloc(ContextID, 256);
Tables[i]->Table16[j] = (cmsUInt16Number) FROM_8_TO_16(Temp[j]);
}
- _cmsFree(ContextID, Temp);
+ _cmsFree(ContextID, Temp);
Temp = NULL;
cmsPipelineInsertStage(lut, cmsAT_END, mpe);
- for (i=0; i < nChannels; i++)
+ for (i=0; i < nChannels; i++)
cmsFreeToneCurve(Tables[i]);
return TRUE;
}
if (Temp) _cmsFree(ContextID, Temp);
- return FALSE;
+ return FALSE;
}
// Check overflow
static
-unsigned int uipow(cmsUInt32Number n, cmsUInt32Number a, cmsUInt32Number b)
+size_t uipow(cmsUInt32Number n, cmsUInt32Number a, cmsUInt32Number b)
{
cmsUInt32Number rv = 1, rc;
if (n == 0) return 0;
for (; b > 0; b--) {
-
+
rv *= a;
// Check for overflow
- if (rv > UINT_MAX / a) return 0;
+ if (rv > UINT_MAX / a) return (size_t) -1;
}
-
+
rc = rv * n;
- if (rv != rc / n) return 0;
+ if (rv != rc / n) return (size_t) -1;
return rc;
}
-// That will create a MPE LUT with Matrix, pre tables, CLUT and post tables.
+// That will create a MPE LUT with Matrix, pre tables, CLUT and post tables.
// 8 bit lut may be scaled easely to v4 PCS, but we need also to properly adjust
// PCS on BToAxx tags and AtoB if abstract. We need to fix input direction.
cmsUInt8Number* Temp = NULL;
cmsPipeline* NewLUT = NULL;
cmsStage *mpemat, *mpeclut;
- cmsUInt32Number nTabSize, i;
+ cmsUInt32Number nTabSize, i;
cmsFloat64Number Matrix[3*3];
*nItems = 0;
-
+
if (!_cmsReadUInt8Number(io, &InputChannels)) goto Error;
if (!_cmsReadUInt8Number(io, &OutputChannels)) goto Error;
if (!_cmsReadUInt8Number(io, &CLUTpoints)) goto Error;
+ if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
+
// Padding
if (!_cmsReadUInt8Number(io, NULL)) goto Error;
// Do some checking
-
+
if (InputChannels > cmsMAXCHANNELS) goto Error;
if (OutputChannels > cmsMAXCHANNELS) goto Error;
if (!_cmsRead15Fixed16Number(io, &Matrix[7])) goto Error;
if (!_cmsRead15Fixed16Number(io, &Matrix[8])) goto Error;
-
+
// Only operates if not identity...
if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
if (mpemat == NULL) goto Error;
cmsPipelineInsertStage(NewLUT, cmsAT_BEGIN, mpemat);
}
-
+
// Get input tables
if (!Read8bitTables(self ->ContextID, io, NewLUT, InputChannels)) goto Error;
-
+
// Get 3D CLUT. Check the overflow....
nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
+ if (nTabSize == (size_t) -1) goto Error;
if (nTabSize > 0) {
cmsUInt16Number *PtrW, *T;
PtrW = T = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));
if (T == NULL) goto Error;
- Temp = (cmsUInt8Number*) _cmsMalloc(self ->ContextID, nTabSize);
+ Temp = (cmsUInt8Number*) _cmsMalloc(self ->ContextID, nTabSize);
if (Temp == NULL) goto Error;
if (io ->Read(io, Temp, nTabSize, 1) != 1) goto Error;
_cmsFree(self ->ContextID, Temp);
Temp = NULL;
-
+
mpeclut = cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T);
if (mpeclut == NULL) goto Error;
cmsPipelineInsertStage(NewLUT, cmsAT_END, mpeclut);
// Get output tables
if (!Read8bitTables(self ->ContextID, io, NewLUT, OutputChannels)) goto Error;
-
+
*nItems = 1;
return NewLUT;
if (!Write8bitTables(self ->ContextID, io, NewLUT ->InputChannels, PreMPE)) return FALSE;
nTabSize = uipow(NewLUT->OutputChannels, clutPoints, NewLUT ->InputChannels);
+ if (nTabSize == (size_t) -1) return FALSE;
if (nTabSize > 0) {
// The 3D CLUT.
static
void Type_LUT8_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsPipelineFree((cmsPipeline*) Ptr);
return;
// ********************************************************************************
// Read 16 bit tables as gamma functions
-static
+static
cmsBool Read16bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, int nChannels, int nEntries)
{
cmsStage* mpe;
if (nEntries <= 0) return TRUE;
// Check for malicious profiles
+ if (nEntries < 2) return FALSE;
if (nChannels > cmsMAXCHANNELS) return FALSE;
-
+
// Init table to zero
memset(Tables, 0, sizeof(Tables));
cmsPipelineInsertStage(lut, cmsAT_END, mpe);
- for (i=0; i < nChannels; i++)
+ for (i=0; i < nChannels; i++)
cmsFreeToneCurve(Tables[i]);
return TRUE;
if (Tables[i]) cmsFreeToneCurve(Tables[i]);
}
- return FALSE;
+ return FALSE;
}
static
int nEntries = 256;
nEntries = Tables->TheCurves[0]->nEntries;
-
+
for (i=0; i < Tables ->nCurves; i++) {
for (j=0; j < nEntries; j++) {
cmsUInt32Number nTabSize;
cmsFloat64Number Matrix[3*3];
cmsUInt16Number InputEntries, OutputEntries;
-
+
*nItems = 0;
if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL;
if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL;
if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL; // 255 maximum
-
+
// Padding
if (!_cmsReadUInt8Number(io, NULL)) return NULL;
// Only operates on 3 channels
-
if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
mpemat = cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL);
cmsPipelineInsertStage(NewLUT, cmsAT_END, mpemat);
}
- if (!_cmsReadUInt16Number(io, &InputEntries)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputEntries)) return NULL;
+ if (!_cmsReadUInt16Number(io, &InputEntries)) goto Error;
+ if (!_cmsReadUInt16Number(io, &OutputEntries)) goto Error;
+
+ if (InputEntries > 0x7FFF || OutputEntries > 0x7FFF) goto Error;
+ if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
-
// Get input tables
if (!Read16bitTables(self ->ContextID, io, NewLUT, InputChannels, InputEntries)) goto Error;
// Get 3D CLUT
nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
+ if (nTabSize == (size_t) -1) goto Error;
if (nTabSize > 0) {
cmsUInt16Number *T;
if (!_cmsReadUInt16Array(io, nTabSize, T)) {
_cmsFree(self ->ContextID, T);
- goto Error;
+ goto Error;
}
-
+
mpeclut = cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T);
if (mpeclut == NULL) {
_cmsFree(self ->ContextID, T);
cmsUNUSED_PARAMETER(SizeOfTag);
}
-// We only allow some specific MPE structures: Matrix plus prelin, plus clut, plus post-lin.
+// We only allow some specific MPE structures: Matrix plus prelin, plus clut, plus post-lin.
// Some empty defaults are created for missing parts
static
MatMPE = (_cmsStageMatrixData*) mpe ->Data;
mpe = mpe -> Next;
}
-
+
if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
mpe = mpe -> Next;
}
-
+
if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
clut = (_cmsStageCLutData*) mpe -> Data;
mpe = mpe ->Next;
}
-
+
if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
mpe = mpe -> Next;
InputChannels = cmsPipelineInputChannels(NewLUT);
OutputChannels = cmsPipelineOutputChannels(NewLUT);
-
+
if (clut == NULL)
clutPoints = 0;
else
if (MatMPE != NULL) {
-
+
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PostMPE ->TheCurves[0]->nEntries)) return FALSE;
} else {
if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
-
+
}
// The prelinearization table
}
nTabSize = uipow(OutputChannels, clutPoints, InputChannels);
-
+ if (nTabSize == (size_t) -1) return FALSE;
if (nTabSize > 0) {
// The 3D CLUT.
if (clut != NULL) {
static
void Type_LUT16_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsPipelineFree((cmsPipeline*) Ptr);
return;
cmsFloat64Number dOff[3];
cmsStage* Mat;
- // Go to address
+ // Go to address
if (!io -> Seek(io, Offset)) return NULL;
// Read the Matrix
if (!_cmsRead15Fixed16Number(io, &dOff[0])) return NULL;
if (!_cmsRead15Fixed16Number(io, &dOff[1])) return NULL;
if (!_cmsRead15Fixed16Number(io, &dOff[2])) return NULL;
-
+
Mat = cmsStageAllocMatrix(self ->ContextID, 3, 3, dMat, dOff);
return Mat;
static
cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, int InputChannels, int OutputChannels)
{
- cmsUInt8Number gridPoints8[cmsMAXCHANNELS]; // Number of grid points in each dimension.
+ cmsUInt8Number gridPoints8[cmsMAXCHANNELS]; // Number of grid points in each dimension.
cmsUInt32Number GridPoints[cmsMAXCHANNELS], i;
cmsUInt8Number Precision;
cmsStage* CLUT;
if (!io -> Seek(io, Offset)) return NULL;
if (io -> Read(io, gridPoints8, cmsMAXCHANNELS, 1) != 1) return NULL;
- for (i=0; i < cmsMAXCHANNELS; i++)
+
+ for (i=0; i < cmsMAXCHANNELS; i++) {
+
+ if (gridPoints8[i] == 1) return NULL; // Impossible value, 0 for no CLUT and then 2 at least
GridPoints[i] = gridPoints8[i];
+ }
if (!_cmsReadUInt8Number(io, &Precision)) return NULL;
if (Precision == 1) {
cmsUInt8Number v;
-
+
for (i=0; i < Data ->nEntries; i++) {
if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL;
Data ->Tab.T[i] = FROM_8_TO_16(v);
}
-
+
}
- else
+ else
if (Precision == 2) {
-
+
if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) return NULL;
}
else {
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
+ cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
return NULL;
}
-
+
return CLUT;
}
cmsTagTypeSignature BaseType;
cmsUInt32Number nItems;
- BaseType = _cmsReadTypeBase(io);
+ BaseType = _cmsReadTypeBase(io);
switch (BaseType) {
case cmsSigCurveType:
case cmsSigParametricCurveType:
return (cmsToneCurve*) Type_ParametricCurve_Read(self, io, &nItems, 0);
- default:
+ default:
{
char String[5];
// Read a set of curves from specific offset
static
cmsStage* ReadSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, cmsUInt32Number nCurves)
-{
+{
cmsToneCurve* Curves[cmsMAXCHANNELS];
cmsUInt32Number i;
cmsStage* Lin = NULL;
if (!io -> Seek(io, Offset)) return FALSE;
- for (i=0; i < nCurves; i++)
+ for (i=0; i < nCurves; i++)
Curves[i] = NULL;
for (i=0; i < nCurves; i++) {
- Curves[i] = ReadEmbeddedCurve(self, io);
+ Curves[i] = ReadEmbeddedCurve(self, io);
if (Curves[i] == NULL) goto Error;
- if (!_cmsReadAlignment(io)) goto Error;
+ if (!_cmsReadAlignment(io)) goto Error;
+
}
Lin = cmsStageAllocToneCurves(self ->ContextID, nCurves, Curves);
Error:
- for (i=0; i < nCurves; i++)
+ for (i=0; i < nCurves; i++)
cmsFreeToneCurve(Curves[i]);
return Lin;
}
-// LutAtoB type
+// LutAtoB type
-// This structure represents a colour transform. The type contains up to five processing
-// elements which are stored in the AtoBTag tag in the following order: a set of one
-// dimensional curves, a 3 by 3 matrix with offset terms, a set of one dimensional curves,
+// This structure represents a colour transform. The type contains up to five processing
+// elements which are stored in the AtoBTag tag in the following order: a set of one
+// dimensional curves, a 3 by 3 matrix with offset terms, a set of one dimensional curves,
// a multidimensional lookup table, and a set of one dimensional output curves.
// Data are processed using these elements via the following sequence:
//
//("A" curves) -> (multidimensional lookup table - CLUT) -> ("M" curves) -> (matrix) -> ("B" curves).
//
/*
-It is possible to use any or all of these processing elements. At least one processing element
+It is possible to use any or all of these processing elements. At least one processing element
must be included.Only the following combinations are allowed:
B
void* Type_LUTA2B_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
cmsUInt32Number BaseOffset;
- cmsUInt8Number inputChan; // Number of input channels
- cmsUInt8Number outputChan; // Number of output channels
- cmsUInt32Number offsetB; // Offset to first "B" curve
- cmsUInt32Number offsetMat; // Offset to matrix
- cmsUInt32Number offsetM; // Offset to first "M" curve
- cmsUInt32Number offsetC; // Offset to CLUT
+ cmsUInt8Number inputChan; // Number of input channels
+ cmsUInt8Number outputChan; // Number of output channels
+ cmsUInt32Number offsetB; // Offset to first "B" curve
+ cmsUInt32Number offsetMat; // Offset to matrix
+ cmsUInt32Number offsetM; // Offset to first "M" curve
+ cmsUInt32Number offsetC; // Offset to CLUT
cmsUInt32Number offsetA; // Offset to first "A" curve
cmsStage* mpe;
cmsPipeline* NewLUT = NULL;
if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
-
+
if (!_cmsReadUInt16Number(io, NULL)) return NULL;
-
+
if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
if (offsetA!= 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetA, inputChan);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
if (offsetC != 0) {
mpe = ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
if (offsetM != 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetM, outputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
- if (offsetMat != 0) {
+ if (offsetMat != 0) {
mpe = ReadMatrix(self, io, BaseOffset + offsetMat);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
- if (offsetB != 0) {
+ if (offsetB != 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetB, outputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
-
+
*nItems = 1;
return NewLUT;
// Write a set of curves
static
cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe)
-{
+{
_cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data;
// Write the Matrix
// Write a set of curves
static
cmsBool WriteSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsTagTypeSignature Type, cmsStage* mpe)
-{
+{
cmsUInt32Number i, n;
cmsTagTypeSignature CurrentType;
cmsToneCurve** Curves;
// If this is a table-based curve, use curve type even on V4
CurrentType = Type;
- if ((Curves[i] ->nSegments == 0)||(Curves[i]->nSegments == 2) && (Curves[i] ->Segments[1].Type == 0))
+ if ((Curves[i] ->nSegments == 0)||
+ ((Curves[i]->nSegments == 2) && (Curves[i] ->Segments[1].Type == 0)) )
CurrentType = cmsSigCurveType;
else
if (Curves[i] ->Segments[0].Type < 0)
if (!Type_ParametricCurve_Write(self, io, Curves[i], 1)) return FALSE;
break;
- default:
+ default:
{
char String[5];
_cmsTagSignature2String(String, (cmsTagSignature) Type);
cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String);
- }
+ }
return FALSE;
}
static
cmsBool WriteCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt8Number Precision, cmsStage* mpe)
{
- cmsUInt8Number gridPoints[cmsMAXCHANNELS]; // Number of grid points in each dimension.
- cmsUInt32Number i;
+ cmsUInt8Number gridPoints[cmsMAXCHANNELS]; // Number of grid points in each dimension.
+ cmsUInt32Number i;
_cmsStageCLutData* CLUT = ( _cmsStageCLutData*) mpe -> Data;
if (CLUT ->HasFloatValues) {
- cmsSignalError(self ->ContextID, cmsERROR_NOT_SUITABLE, "Cannot save floating point data, CLUT are 8 or 16 bit only");
+ cmsSignalError(self ->ContextID, cmsERROR_NOT_SUITABLE, "Cannot save floating point data, CLUT are 8 or 16 bit only");
return FALSE;
}
memset(gridPoints, 0, sizeof(gridPoints));
- for (i=0; i < (cmsUInt32Number) CLUT ->Params ->nInputs; i++)
+ for (i=0; i < (cmsUInt32Number) CLUT ->Params ->nInputs; i++)
gridPoints[i] = (cmsUInt8Number) CLUT ->Params ->nSamples[i];
if (!io -> Write(io, cmsMAXCHANNELS*sizeof(cmsUInt8Number), gridPoints)) return FALSE;
for (i=0; i < CLUT->nEntries; i++) {
- if (!_cmsWriteUInt8Number(io, FROM_16_TO_8(CLUT->Tab.T[i]))) return FALSE;
+ if (!_cmsWriteUInt8Number(io, FROM_16_TO_8(CLUT->Tab.T[i]))) return FALSE;
}
}
- else
+ else
if (Precision == 2) {
if (!_cmsWriteUInt16Array(io, CLUT->nEntries, CLUT ->Tab.T)) return FALSE;
}
else {
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
+ cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
return FALSE;
}
if (Lut ->Elements != NULL)
if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &M, &Matrix, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &A, &CLUT, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType,
- cmsSigMatrixElemType, cmsSigCurveSetElemType, &A, &CLUT, &M, &Matrix, &B)) {
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &M, &Matrix, &B))
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &A, &CLUT, &B))
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType,
+ cmsSigMatrixElemType, cmsSigCurveSetElemType, &A, &CLUT, &M, &Matrix, &B)) {
cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutAToB");
return FALSE;
offsetA = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
}
-
+
if (CLUT != NULL) {
offsetC = io ->Tell(io) - BaseOffset;
if (!WriteCLUT(self, io, Lut ->SaveAs8Bits ? 1 : 2, CLUT)) return FALSE;
offsetM = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
}
-
+
if (Matrix != NULL) {
offsetMat = io ->Tell(io) - BaseOffset;
if (!WriteMatrix(self, io, Matrix)) return FALSE;
offsetB = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
}
-
+
CurrentPos = io ->Tell(io);
if (!io ->Seek(io, DirectoryPos)) return FALSE;
if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
if (!io ->Seek(io, CurrentPos)) return FALSE;
-
+
return TRUE;
cmsUNUSED_PARAMETER(nItems);
static
void Type_LUTA2B_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsPipelineFree((cmsPipeline*) Ptr);
return;
}
-// LutBToA type
+// LutBToA type
static
void* Type_LUTB2A_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
- cmsUInt8Number inputChan; // Number of input channels
- cmsUInt8Number outputChan; // Number of output channels
+ cmsUInt8Number inputChan; // Number of input channels
+ cmsUInt8Number outputChan; // Number of output channels
cmsUInt32Number BaseOffset; // Actual position in file
- cmsUInt32Number offsetB; // Offset to first "B" curve
- cmsUInt32Number offsetMat; // Offset to matrix
- cmsUInt32Number offsetM; // Offset to first "M" curve
- cmsUInt32Number offsetC; // Offset to CLUT
+ cmsUInt32Number offsetB; // Offset to first "B" curve
+ cmsUInt32Number offsetMat; // Offset to matrix
+ cmsUInt32Number offsetM; // Offset to first "M" curve
+ cmsUInt32Number offsetC; // Offset to CLUT
cmsUInt32Number offsetA; // Offset to first "A" curve
cmsStage* mpe;
cmsPipeline* NewLUT = NULL;
// Padding
if (!_cmsReadUInt16Number(io, NULL)) return NULL;
-
+
if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
// Allocates an empty LUT
NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
if (NewLUT == NULL) return NULL;
-
- if (offsetB != 0) {
+
+ if (offsetB != 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetB, inputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
- if (offsetMat != 0) {
+ if (offsetMat != 0) {
mpe = ReadMatrix(self, io, BaseOffset + offsetMat);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
if (offsetM != 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetM, inputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
if (offsetC != 0) {
mpe = ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
if (offsetA!= 0) {
mpe = ReadSetOfCurves(self, io, BaseOffset + offsetA, outputChan);
- if (mpe != NULL) cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
+ if (mpe == NULL) { cmsPipelineFree(NewLUT); return NULL; }
+ cmsPipelineInsertStage(NewLUT, cmsAT_END, mpe);
}
*nItems = 1;
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &B, &Matrix, &M))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &CLUT, &A))
- if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
- cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &Matrix, &M, &CLUT, &A)) {
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &B, &Matrix, &M))
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &CLUT, &A))
+ if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
+ cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &Matrix, &M, &CLUT, &A)) {
cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutBToA");
return FALSE;
}
inputChan = cmsPipelineInputChannels(Lut);
outputChan = cmsPipelineOutputChannels(Lut);
-
+
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) inputChan)) return FALSE;
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) outputChan)) return FALSE;
if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
DirectoryPos = io ->Tell(io);
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
- if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
offsetA = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
}
-
+
if (CLUT != NULL) {
offsetC = io ->Tell(io) - BaseOffset;
if (!WriteCLUT(self, io, Lut ->SaveAs8Bits ? 1 : 2, CLUT)) return FALSE;
offsetM = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
}
-
+
if (Matrix != NULL) {
offsetMat = io ->Tell(io) - BaseOffset;
- if (!WriteMatrix(self, io, Matrix)) return FALSE;
+ if (!WriteMatrix(self, io, Matrix)) return FALSE;
}
if (B != NULL) {
offsetB = io ->Tell(io) - BaseOffset;
if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
}
-
+
CurrentPos = io ->Tell(io);
if (!io ->Seek(io, DirectoryPos)) return FALSE;
if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
if (!io ->Seek(io, CurrentPos)) return FALSE;
-
+
return TRUE;
cmsUNUSED_PARAMETER(nItems);
static
void Type_LUTB2A_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsPipelineFree((cmsPipeline*) Ptr);
return;
// Type cmsSigColorantTableType
// ********************************************************************************
/*
-The purpose of this tag is to identify the colorants used in the profile by a
-unique name and set of XYZ or L*a*b* values to give the colorant an unambiguous
+The purpose of this tag is to identify the colorants used in the profile by a
+unique name and set of XYZ or L*a*b* values to give the colorant an unambiguous
value. The first colorant listed is the colorant of the first device channel of
a lut tag. The second colorant listed is the colorant of the second device channel
of a lut tag, and so on.
cmsUInt32Number i, Count;
cmsNAMEDCOLORLIST* List;
char Name[34];
- cmsUInt16Number PCS[3];
+ cmsUInt16Number PCS[3];
if (!_cmsReadUInt32Number(io, &Count)) return NULL;
if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
- if (!cmsAppendNamedColor(List, Name, PCS, NULL)) goto Error;
-
+ if (!cmsAppendNamedColor(List, Name, PCS, NULL)) goto Error;
+
}
*nItems = 1;
static
cmsBool Type_ColorantTable_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
+ cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
int i, nColors;
nColors = cmsNamedColorCount(NamedColorList);
for (i=0; i < nColors; i++) {
char root[33];
- cmsUInt16Number PCS[3];
+ cmsUInt16Number PCS[3];
if (!cmsNamedColorInfo(NamedColorList, i, root, NULL, NULL, PCS, NULL)) return 0;
root[32] = 0;
void* Type_ColorantTable_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
{
cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) Ptr;
- return (void*) cmsDupNamedColorList(nc);
+ return (void*) cmsDupNamedColorList(nc);
cmsUNUSED_PARAMETER(n);
cmsUNUSED_PARAMETER(self);
static
void Type_ColorantTable_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
return;
// Type cmsSigNamedColor2Type
// ********************************************************************************
//
-//The namedColor2Type is a count value and array of structures that provide color
-//coordinates for 7-bit ASCII color names. For each named color, a PCS and optional
-//device representation of the color are given. Both representations are 16-bit values.
-//The device representation corresponds to the header\92s \93color space of data\94 field.
+//The namedColor2Type is a count value and array of structures that provide color
+//coordinates for 7-bit ASCII color names. For each named color, a PCS and optional
+//device representation of the color are given. Both representations are 16-bit values.
+//The device representation corresponds to the header\92s \93color space of data\94 field.
//This representation should be consistent with the \93number of device components\94
//field in the namedColor2Type. If this field is 0, device coordinates are not provided.
-//The PCS representation corresponds to the header\92s PCS field. The PCS representation
-//is always provided. Color names are fixed-length, 32-byte fields including null
-//termination. In order to maintain maximum portability, it is strongly recommended
+//The PCS representation corresponds to the header\92s PCS field. The PCS representation
+//is always provided. Color names are fixed-length, 32-byte fields including null
+//termination. In order to maintain maximum portability, it is strongly recommended
//that special characters of the 7-bit ASCII set not be used.
static
void *Type_NamedColor_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
- cmsUInt32Number vendorFlag; // Bottom 16 bits for ICC use
- cmsUInt32Number count; // Count of named colors
- cmsUInt32Number nDeviceCoords; // Num of device coordinates
- char prefix[32]; // Prefix for each color name
- char suffix[32]; // Suffix for each color name
+ cmsUInt32Number vendorFlag; // Bottom 16 bits for ICC use
+ cmsUInt32Number count; // Count of named colors
+ cmsUInt32Number nDeviceCoords; // Num of device coordinates
+ char prefix[32]; // Prefix for each color name
+ char suffix[32]; // Suffix for each color name
cmsNAMEDCOLORLIST* v;
cmsUInt32Number i;
cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
- char prefix[32]; // Prefix for each color name
- char suffix[32]; // Suffix for each color name
+ char prefix[32]; // Prefix for each color name
+ char suffix[32]; // Suffix for each color name
int i, nColors;
nColors = cmsNamedColorCount(NamedColorList);
if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0;
if (!io ->Write(io, 32 , Root)) return FALSE;
- if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
+ if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
if (!_cmsWriteUInt16Array(io, NamedColorList ->ColorantCount, Colorant)) return FALSE;
}
static
void Type_NamedColor_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
return;
// Type cmsSigProfileSequenceDescType
// ********************************************************************************
-// This type is an array of structures, each of which contains information from the
-// header fields and tags from the original profiles which were combined to create
-// the final profile. The order of the structures is the order in which the profiles
-// were combined and includes a structure for the final profile. This provides a
-// description of the profile sequence from source to destination,
+// This type is an array of structures, each of which contains information from the
+// header fields and tags from the original profiles which were combined to create
+// the final profile. The order of the structures is the order in which the profiles
+// were combined and includes a structure for the final profile. This provides a
+// description of the profile sequence from source to destination,
// typically used with the DeviceLink profile.
static
cmsTagTypeSignature BaseType;
cmsUInt32Number nItems;
- BaseType = _cmsReadTypeBase(io);
+ BaseType = _cmsReadTypeBase(io);
switch (BaseType) {
case cmsSigTextType:
if (*mlu) cmsMLUfree(*mlu);
*mlu = (cmsMLU*)Type_Text_Read(self, io, &nItems, SizeOfTag);
- return (*mlu != NULL);
+ return (*mlu != NULL);
case cmsSigTextDescriptionType:
if (*mlu) cmsMLUfree(*mlu);
*mlu = (cmsMLU*) Type_Text_Description_Read(self, io, &nItems, SizeOfTag);
- return (*mlu != NULL);
+ return (*mlu != NULL);
/*
TBD: Size is needed for MLU, and we have no idea on which is the available size
{
cmsSEQ* OutSeq;
cmsUInt32Number i, Count;
-
+
*nItems = 0;
-
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
+
+ if (!_cmsReadUInt32Number(io, &Count)) return NULL;
if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
SizeOfTag -= sizeof(cmsUInt32Number);
-
+
OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
if (OutSeq == NULL) return NULL;
OutSeq ->n = Count;
-
+
// Get structures as well
for (i=0; i < Count; i++) {
-
+
cmsPSEQDESC* sec = &OutSeq -> seq[i];
- if (!_cmsReadUInt32Number(io, &sec ->deviceMfg)) return NULL;
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
+ if (!_cmsReadUInt32Number(io, &sec ->deviceMfg)) goto Error;
+ if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
SizeOfTag -= sizeof(cmsUInt32Number);
- if (!_cmsReadUInt32Number(io, &sec ->deviceModel)) return NULL;
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
+ if (!_cmsReadUInt32Number(io, &sec ->deviceModel)) goto Error;
+ if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
SizeOfTag -= sizeof(cmsUInt32Number);
- if (!_cmsReadUInt64Number(io, &sec ->attributes)) return NULL;
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
+ if (!_cmsReadUInt64Number(io, &sec ->attributes)) goto Error;
+ if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
SizeOfTag -= sizeof(cmsUInt64Number);
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number *)&sec ->technology)) return NULL;
- if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
+ if (!_cmsReadUInt32Number(io, (cmsUInt32Number *)&sec ->technology)) goto Error;
+ if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
SizeOfTag -= sizeof(cmsUInt32Number);
- if (!ReadEmbeddedText(self, io, &sec ->Manufacturer, SizeOfTag)) return NULL;
- if (!ReadEmbeddedText(self, io, &sec ->Model, SizeOfTag)) return NULL;
+ if (!ReadEmbeddedText(self, io, &sec ->Manufacturer, SizeOfTag)) goto Error;
+ if (!ReadEmbeddedText(self, io, &sec ->Model, SizeOfTag)) goto Error;
}
*nItems = 1;
return OutSeq;
+
+Error:
+ cmsFreeProfileSequenceDescription(OutSeq);
+ return NULL;
}
static
cmsBool SaveDescription(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* Text)
{
- if (self ->ICCVersion < 0x4000000) {
+ if (self ->ICCVersion < 0x4000000) {
if (!_cmsWriteTypeBase(io, cmsSigTextDescriptionType)) return FALSE;
return Type_Text_Description_Write(self, io, Text, 1);
cmsUInt32Number i;
if (!_cmsWriteUInt32Number(io, Seq->n)) return FALSE;
-
+
for (i=0; i < Seq ->n; i++) {
cmsPSEQDESC* sec = &Seq -> seq[i];
if (!_cmsWriteUInt32Number(io, sec ->deviceMfg)) return FALSE;
if (!_cmsWriteUInt32Number(io, sec ->deviceModel)) return FALSE;
- if (!_cmsWriteUInt64Number(io, sec ->attributes)) return FALSE;
+ if (!_cmsWriteUInt64Number(io, &sec ->attributes)) return FALSE;
if (!_cmsWriteUInt32Number(io, sec ->technology)) return FALSE;
-
- if (!SaveDescription(self, io, sec ->Manufacturer)) return FALSE;
- if (!SaveDescription(self, io, sec ->Model)) return FALSE;
+
+ if (!SaveDescription(self, io, sec ->Manufacturer)) return FALSE;
+ if (!SaveDescription(self, io, sec ->Model)) return FALSE;
}
-
- return TRUE;
+
+ return TRUE;
cmsUNUSED_PARAMETER(nItems);
}
static
void* Type_ProfileSequenceDesc_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
+{
return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
cmsUNUSED_PARAMETER(n);
static
void Type_ProfileSequenceDesc_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
return;
// Type cmsSigProfileSequenceIdType
// ********************************************************************************
/*
-In certain workflows using ICC Device Link Profiles, it is necessary to identify the
+In certain workflows using ICC Device Link Profiles, it is necessary to identify the
original profiles that were combined to create the Device Link Profile.
-This type is an array of structures, each of which contains information for
+This type is an array of structures, each of which contains information for
identification of a profile used in a sequence
*/
static
-cmsBool ReadSeqID(struct _cms_typehandler_struct* self,
+cmsBool ReadSeqID(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
cmsSEQ* OutSeq = (cmsSEQ*) Cargo;
cmsPSEQDESC* seq = &OutSeq ->seq[n];
-
+
if (io -> Read(io, seq ->ProfileID.ID8, 16, 1) != 1) return FALSE;
if (!ReadEmbeddedText(self, io, &seq ->Description, SizeOfTag)) return FALSE;
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
// Get table count
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
+ if (!_cmsReadUInt32Number(io, &Count)) return NULL;
SizeOfTag -= sizeof(cmsUInt32Number);
// Allocate an empty structure
static
-cmsBool WriteSeqID(struct _cms_typehandler_struct* self,
+cmsBool WriteSeqID(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
cmsSEQ* Seq = (cmsSEQ*) Cargo;
-
+
if (!io ->Write(io, 16, Seq ->seq[n].ProfileID.ID8)) return FALSE;
// Store here the MLU
- if (!SaveDescription(self, io, Seq ->seq[n].Description)) return FALSE;
+ if (!SaveDescription(self, io, Seq ->seq[n].Description)) return FALSE;
return TRUE;
// Keep the base offset
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
-
+
// This is the table count
if (!_cmsWriteUInt32Number(io, Seq ->n)) return FALSE;
// This is the position table and content
if (!WritePositionTable(self, io, 0, Seq ->n, BaseOffset, Seq, WriteSeqID)) return FALSE;
-
+
return TRUE;
cmsUNUSED_PARAMETER(nItems);
static
void* Type_ProfileSequenceId_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
-{
+{
return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
cmsUNUSED_PARAMETER(n);
static
void Type_ProfileSequenceId_Free(struct _cms_typehandler_struct* self, void* Ptr)
-{
+{
cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
return;
if (!_cmsWriteUInt32Number(io, Value ->Ucr ->nEntries)) return FALSE;
if (!_cmsWriteUInt16Array(io, Value ->Ucr ->nEntries, Value ->Ucr ->Table16)) return FALSE;
- // Then black generation
+ // Then black generation
if (!_cmsWriteUInt32Number(io, Value ->Bg ->nEntries)) return FALSE;
if (!_cmsWriteUInt16Array(io, Value ->Bg ->nEntries, Value ->Bg ->Table16)) return FALSE;
Text = (char*) _cmsMalloc(self ->ContextID, TextSize);
if (cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, Text, TextSize) != TextSize) return FALSE;
- if (!io ->Write(io, TextSize, Text)) return FALSE;
+ if (!io ->Write(io, TextSize, Text)) return FALSE;
_cmsFree(self ->ContextID, Text);
return TRUE;
void Type_UcrBg_Free(struct _cms_typehandler_struct* self, void *Ptr)
{
cmsUcrBg* Src = (cmsUcrBg*) Ptr;
-
+
if (Src ->Ucr) cmsFreeToneCurve(Src ->Ucr);
if (Src ->Bg) cmsFreeToneCurve(Src ->Bg);
if (Src ->Desc) cmsMLUfree(Src ->Desc);
-
+
_cmsFree(self ->ContextID, Ptr);
}
cmsUInt32Number Count;
char* Text;
- if (*SizeOfTag < sizeof(cmsUInt32Number)) return FALSE;
-
+ if (*SizeOfTag < sizeof(cmsUInt32Number)) return FALSE;
+
if (!_cmsReadUInt32Number(io, &Count)) return FALSE;
if (Count > UINT_MAX - sizeof(cmsUInt32Number)) return FALSE;
- if (*SizeOfTag < Count + sizeof(cmsUInt32Number)) return FALSE;
+ if (*SizeOfTag < Count + sizeof(cmsUInt32Number)) return FALSE;
Text = (char*) _cmsMalloc(self ->ContextID, Count+1);
if (Text == NULL) return FALSE;
}
Text[Count] = 0;
-
+
cmsMLUsetASCII(mlu, "PS", Section, Text);
_cmsFree(self ->ContextID, Text);
*SizeOfTag -= (Count + sizeof(cmsUInt32Number));
- return TRUE;
+ return TRUE;
}
static
cmsBool WriteCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, const char* Section)
{
cmsUInt32Number TextSize;
- char* Text;
-
+ char* Text;
+
TextSize = cmsMLUgetASCII(mlu, "PS", Section, NULL, 0);
Text = (char*) _cmsMalloc(self ->ContextID, TextSize);
- if (!_cmsWriteUInt32Number(io, TextSize)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, TextSize)) return FALSE;
if (cmsMLUgetASCII(mlu, "PS", Section, Text, TextSize) == 0) return FALSE;
- if (!io ->Write(io, TextSize, Text)) return FALSE;
+ if (!io ->Write(io, TextSize, Text)) return FALSE;
_cmsFree(self ->ContextID, Text);
return TRUE;
if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#1")) goto Error;
if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#2")) goto Error;
if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#3")) goto Error;
-
+
*nItems = 1;
return (void*) mlu;
static
void Type_CrdInfo_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
+{
cmsMLUfree((cmsMLU*) Ptr);
return;
{
cmsScreening* sc = NULL;
cmsUInt32Number i;
-
+
sc = (cmsScreening*) _cmsMallocZero(self ->ContextID, sizeof(cmsScreening));
if (sc == NULL) return NULL;
*nItems = 0;
-
+
if (!_cmsReadUInt32Number(io, &sc ->Flag)) goto Error;
if (!_cmsReadUInt32Number(io, &sc ->nChannels)) goto Error;
for (i=0; i < sc ->nChannels; i++) {
- if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].Frequency)) goto Error;
- if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].ScreenAngle)) goto Error;
+ if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].Frequency)) goto Error;
+ if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].ScreenAngle)) goto Error;
if (!_cmsReadUInt32Number(io, &sc ->Channels[i].SpotShape)) goto Error;
}
return (void*) sc;
Error:
- if (sc != NULL)
+ if (sc != NULL)
_cmsFree(self ->ContextID, sc);
return NULL;
static
cmsBool Type_Screening_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsScreening* sc = (cmsScreening* ) Ptr;
+ cmsScreening* sc = (cmsScreening* ) Ptr;
cmsUInt32Number i;
-
+
if (!_cmsWriteUInt32Number(io, sc ->Flag)) return FALSE;
if (!_cmsWriteUInt32Number(io, sc ->nChannels)) return FALSE;
// Type cmsSigViewingConditionsType
// ********************************************************************************
//
-//This type represents a set of viewing condition parameters including:
-//CIE \92absolute\92 illuminant white point tristimulus values and CIE \92absolute\92
+//This type represents a set of viewing condition parameters including:
+//CIE \92absolute\92 illuminant white point tristimulus values and CIE \92absolute\92
//surround tristimulus values.
static
void *Type_ViewingConditions_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
{
cmsICCViewingConditions* vc = NULL;
-
+
vc = (cmsICCViewingConditions*) _cmsMallocZero(self ->ContextID, sizeof(cmsICCViewingConditions));
if (vc == NULL) return NULL;
*nItems = 0;
-
+
if (!_cmsReadXYZNumber(io, &vc ->IlluminantXYZ)) goto Error;
if (!_cmsReadXYZNumber(io, &vc ->SurroundXYZ)) goto Error;
if (!_cmsReadUInt32Number(io, &vc ->IlluminantType)) goto Error;
return (void*) vc;
Error:
- if (vc != NULL)
+ if (vc != NULL)
_cmsFree(self ->ContextID, vc);
return NULL;
static
cmsBool Type_ViewingConditions_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
- cmsICCViewingConditions* sc = (cmsICCViewingConditions* ) Ptr;
-
+ cmsICCViewingConditions* sc = (cmsICCViewingConditions* ) Ptr;
+
if (!_cmsWriteXYZNumber(io, &sc ->IlluminantXYZ)) return FALSE;
if (!_cmsWriteXYZNumber(io, &sc ->SurroundXYZ)) return FALSE;
if (!_cmsWriteUInt32Number(io, sc ->IlluminantType)) return FALSE;
static
void GenericMPEfree(struct _cms_typehandler_struct* self, void *Ptr)
-{
+{
cmsStageFree((cmsStage*) Ptr);
return;
// Read an embedded segmented curve
static
cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io)
-{
+{
cmsCurveSegSignature ElementSig;
cmsUInt32Number i, j;
cmsUInt16Number nSegments;
cmsCurveSegment* Segments;
cmsToneCurve* Curve;
cmsFloat32Number PrevBreak = -1E22F; // - infinite
-
+
// Take signature and channels for each element.
- if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return NULL;
+ if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return NULL;
// That should be a segmented curve
if (ElementSig != cmsSigSegmentedCurve) return NULL;
if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) goto Error;
if (!_cmsReadUInt32Number(io, NULL)) goto Error;
-
+
switch (ElementSig) {
case cmsSigFormulaCurveSeg: {
-
+
cmsUInt16Number Type;
cmsUInt32Number ParamsByType[] = {4, 5, 5 };
_cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve element type '%s' found.", String);
}
- return NULL;
+ return NULL;
}
}
static
-cmsBool ReadMPECurve(struct _cms_typehandler_struct* self,
+cmsBool ReadMPECurve(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
cmsToneCurve** GammaTables = ( cmsToneCurve**) Cargo;
cmsCurveSegment* Segments = g ->Segments;
cmsUInt32Number nSegments = g ->nSegments;
- if (!_cmsWriteUInt32Number(io, cmsSigSegmentedCurve)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) nSegments)) goto Error;
- if (!_cmsWriteUInt16Number(io, 0)) goto Error;
+ if (!_cmsWriteUInt32Number(io, cmsSigSegmentedCurve)) goto Error;
+ if (!_cmsWriteUInt32Number(io, 0)) goto Error;
+ if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) nSegments)) goto Error;
+ if (!_cmsWriteUInt16Number(io, 0)) goto Error;
// Write the break-points
for (i=0; i < nSegments - 1; i++) {
for (j=0; j < ParamsByType[Type]; j++) {
if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) ActualSeg ->Params[j])) goto Error;
}
- }
+ }
// It seems there is no need to align. Code is here, and for safety commented out
// if (!_cmsWriteAlignment(io)) goto Error;
static
-cmsBool WriteMPECurve(struct _cms_typehandler_struct* self,
+cmsBool WriteMPECurve(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
_cmsStageToneCurvesData* Curves = (_cmsStageToneCurvesData*) Cargo;
// Write a curve, checking first for validity
static
cmsBool Type_MPEcurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
+{
cmsUInt32Number BaseOffset;
cmsStage* mpe = (cmsStage*) Ptr;
_cmsStageToneCurvesData* Curves = (_cmsStageToneCurvesData*) mpe ->Data;
// Write the header. Since those are curves, input and output channels are same
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
-
- if (!WritePositionTable(self, io, 0,
+
+ if (!WritePositionTable(self, io, 0,
mpe ->InputChannels, BaseOffset, Curves, WriteMPECurve)) return FALSE;
{
cmsStage* mpe;
cmsUInt16Number InputChans, OutputChans;
- cmsUInt32Number nElems, i;
+ cmsUInt32Number nElems, i;
cmsFloat64Number* Matrix;
cmsFloat64Number* Offsets;
if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
+
nElems = InputChans * OutputChans;
// Input and output chans may be ANY (up to 0xffff)
Offsets = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, OutputChans, sizeof(cmsFloat64Number));
if (Offsets == NULL) {
-
+
_cmsFree(self ->ContextID, Matrix);
return NULL;
}
cmsFloat32Number v;
- if (!_cmsReadFloat32Number(io, &v)) return NULL;
+ if (!_cmsReadFloat32Number(io, &v)) return NULL;
Matrix[i] = v;
}
cmsFloat32Number v;
- if (!_cmsReadFloat32Number(io, &v)) return NULL;
+ if (!_cmsReadFloat32Number(io, &v)) return NULL;
Offsets[i] = v;
}
cmsStage* mpe = (cmsStage*) Ptr;
_cmsStageMatrixData* Matrix = (_cmsStageMatrixData*) mpe ->Data;
- if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
nElems = mpe ->InputChannels * mpe ->OutputChannels;
for (i=0; i < nElems; i++) {
- if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Double[i])) return FALSE;
+ if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Double[i])) return FALSE;
}
if (Matrix ->Offset == NULL) {
- if (!_cmsWriteFloat32Number(io, 0)) return FALSE;
+ if (!_cmsWriteFloat32Number(io, 0)) return FALSE;
}
else {
- if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Offset[i])) return FALSE;
+ if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Offset[i])) return FALSE;
}
}
cmsUInt8Number Dimensions8[16];
cmsUInt32Number i, nMaxGrids, GridPoints[MAX_INPUT_DIMENSIONS];
_cmsStageCLutData* clut;
-
+
if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
+
if (io ->Read(io, Dimensions8, sizeof(cmsUInt8Number), 16) != 16)
goto Error;
-
+
// Copy MAX_INPUT_DIMENSIONS at most. Expand to cmsUInt32Number
nMaxGrids = InputChans > MAX_INPUT_DIMENSIONS ? MAX_INPUT_DIMENSIONS : InputChans;
for (i=0; i < nMaxGrids; i++) GridPoints[i] = (cmsUInt32Number) Dimensions8[i];
// Read the data
clut = (_cmsStageCLutData*) mpe ->Data;
for (i=0; i < clut ->nEntries; i++) {
-
+
if (!_cmsReadFloat32Number(io, &clut ->Tab.TFloat[i])) goto Error;
}
- *nItems = 1;
+ *nItems = 1;
return mpe;
Error:
// Write a CLUT in floating point
static
cmsBool Type_MPEclut_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
+{
cmsUInt8Number Dimensions8[16];
cmsUInt32Number i;
cmsStage* mpe = (cmsStage*) Ptr;
// Check for maximum number of channels
if (mpe -> InputChannels > 15) return FALSE;
-
+
// Only floats are supported in MPE
if (clut ->HasFloatValues == FALSE) return FALSE;
memset(Dimensions8, 0, sizeof(Dimensions8));
- for (i=0; i < mpe ->InputChannels; i++)
+ for (i=0; i < mpe ->InputChannels; i++)
Dimensions8[i] = (cmsUInt8Number) clut ->Params ->nSamples[i];
if (!io ->Write(io, 16, Dimensions8)) return FALSE;
for (i=0; i < clut ->nEntries; i++) {
-
+
if (!_cmsWriteFloat32Number(io, clut ->Tab.TFloat[i])) return FALSE;
}
#define DEFAULT_MPE_TYPE_COUNT (sizeof(SupportedMPEtypes) / sizeof(_cmsTagTypeLinkedList))
static
-cmsBool ReadMPEElem(struct _cms_typehandler_struct* self,
+cmsBool ReadMPEElem(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
- cmsUInt32Number n,
+ cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
cmsStageSignature ElementSig;
_cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
- // An unknown element was found.
+ // An unknown element was found.
cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown MPE type '%s' found.", String);
return FALSE;
}
// This is the main dispatcher for MPE
static
void *Type_MPE_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
-{
+{
cmsUInt16Number InputChans, OutputChans;
cmsUInt32Number ElementCount;
cmsPipeline *NewLUT = NULL;
// Read channels and element count
if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
- if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
-
+ if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
+
// Allocates an empty LUT
NewLUT = cmsPipelineAlloc(self ->ContextID, InputChans, OutputChans);
if (NewLUT == NULL) return NULL;
// This one is a liitle bit more complex, so we don't use position tables this time.
static
cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
-{
+{
cmsUInt32Number i, BaseOffset, DirectoryPos, CurrentPos;
int inputChan, outputChan;
cmsUInt32Number ElemCount;
// Write a fake directory to be filled latter on
for (i=0; i < ElemCount; i++) {
- if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
+ if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // size
}
_cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
- // An unknow element was found.
+ // An unknow element was found.
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Found unknown MPE type '%s'", String);
goto Error;
}
- if (!_cmsWriteUInt32Number(io, ElementSig)) goto Error;
- if (!_cmsWriteUInt32Number(io, 0)) goto Error;
+ if (!_cmsWriteUInt32Number(io, ElementSig)) goto Error;
+ if (!_cmsWriteUInt32Number(io, 0)) goto Error;
Before = io ->Tell(io);
if (!TypeHandler ->WritePtr(self, io, Elem, 1)) goto Error;
if (!_cmsWriteAlignment(io)) goto Error;
if (!io ->Seek(io, DirectoryPos)) goto Error;
for (i=0; i < ElemCount; i++) {
- if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
- if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
+ if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
+ if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
}
if (!io ->Seek(io, CurrentPos)) goto Error;
static
void Type_MPE_Free(struct _cms_typehandler_struct* self, void *Ptr)
-{
+{
cmsPipelineFree((cmsPipeline*) Ptr);
return;
static
-void *Type_vcgt_Read(struct _cms_typehandler_struct* self,
- cmsIOHANDLER* io,
- cmsUInt32Number* nItems,
+void *Type_vcgt_Read(struct _cms_typehandler_struct* self,
+ cmsIOHANDLER* io,
+ cmsUInt32Number* nItems,
cmsUInt32Number SizeOfTag)
{
cmsUInt32Number TagType, n, i;
// Read tag type
if (!_cmsReadUInt32Number(io, &TagType)) return NULL;
-
+
// Allocate space for the array
Curves = ( cmsToneCurve**) _cmsCalloc(self ->ContextID, 3, sizeof(cmsToneCurve*));
if (Curves == NULL) return NULL;
switch (TagType) {
// Gamma is stored as a table
- case cmsVideoCardGammaTableType:
+ case cmsVideoCardGammaTableType:
{
cmsUInt16Number nChannels, nElems, nBytes;
if (nChannels != 3) {
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported number of channels for VCGT '%d'", nChannels);
- goto Error;
+ goto Error;
}
// Get Table element count and bytes per element
if (!_cmsReadUInt16Number(io, &nElems)) goto Error;
if (!_cmsReadUInt16Number(io, &nBytes)) goto Error;
-
+
// Adobe's quirk fixup. Fixing broken profiles...
if (nElems == 256 && nBytes == 1 && SizeOfTag == 1576)
nBytes = 2;
// Unsupported
default:
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported bit depth for VCGT '%d'", nBytes * 8);
- goto Error;
+ goto Error;
}
} // For all 3 channels
}
break;
// In this case, gamma is stored as a formula
- case cmsVideoCardGammaFormulaType:
+ case cmsVideoCardGammaFormulaType:
{
_cmsVCGTGAMMA Colorant[3];
-
+
// Populate tone curves
for (n=0; n < 3; n++) {
if (!_cmsRead15Fixed16Number(io, &Colorant[n].Gamma)) goto Error;
if (!_cmsRead15Fixed16Number(io, &Colorant[n].Min)) goto Error;
if (!_cmsRead15Fixed16Number(io, &Colorant[n].Max)) goto Error;
-
+
// Parametric curve type 5 is:
// Y = (aX + b)^Gamma + e | X >= d
// Y = cX + f | X < d
// vcgt formula is:
// Y = (Max \96 Min) * (X ^ Gamma) + Min
-
+
// So, the translation is
- // a = (Max \96 Min) ^ ( 1 / Gamma)
+ // a = (Max \96 Min) ^ ( 1 / Gamma)
// e = Min
// b=c=d=f=0
Params[4] = 0;
Params[5] = Colorant[n].Min;
Params[6] = 0;
-
+
Curves[n] = cmsBuildParametricToneCurve(self ->ContextID, 5, Params);
if (Curves[n] == NULL) goto Error;
}
break;
// Unsupported
- default:
+ default:
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported tag type for VCGT '%d'", TagType);
goto Error;
}
cmsGetToneCurveParametricType(Curves[1]) == 5 &&
cmsGetToneCurveParametricType(Curves[2]) == 5) {
- if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaFormulaType)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaFormulaType)) return FALSE;
// Save parameters
for (i=0; i < 3; i++) {
else {
// Always store as a table of 256 words
- if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaTableType)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 3)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 256)) return FALSE;
- if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
+ if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaTableType)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, 3)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, 256)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
for (i=0; i < 3; i++) {
for (j=0; j < 256; j++) {
cmsFloat32Number v = cmsEvalToneCurveFloat(Curves[i], (cmsFloat32Number) (j / 255.0));
cmsUInt16Number n = _cmsQuickSaturateWord(v * 65535.0);
- if (!_cmsWriteUInt16Number(io, n)) return FALSE;
+ if (!_cmsWriteUInt16Number(io, n)) return FALSE;
}
}
}
if (!_cmsReadUInt32Number(io, &e ->Sizes[i])) return FALSE;
// An offset of zero has special meaning and shal be preserved
- if (e ->Offsets[i] > 0)
+ if (e ->Offsets[i] > 0)
e ->Offsets[i] += BaseOffset;
return TRUE;
}
if (Length > 16) {
if (!ReadOneElem(io, &a ->DisplayName, i, BaseOffset)) return FALSE;
-
+
}
if (Length > 24) {
- if (!ReadOneElem(io, & a -> DisplayValue, i, BaseOffset)) return FALSE;
+ if (!ReadOneElem(io, & a -> DisplayValue, i, BaseOffset)) return FALSE;
}
}
return TRUE;
if (Length > 24) {
- if (!WriteOneElem(io, &a -> DisplayValue, i)) return FALSE;
+ if (!WriteOneElem(io, &a -> DisplayValue, i)) return FALSE;
}
}
{
cmsUInt32Number nChars;
-
- // Special case for undefined strings (see ICC Votable
+
+ // Special case for undefined strings (see ICC Votable
// Proposal Submission, Dictionary Type and Metadata TAG Definition)
if (e -> Offsets[i] == 0) {
- *wcstr = NULL;
+ *wcstr = NULL;
return TRUE;
}
if (!io -> Seek(io, e -> Offsets[i])) return FALSE;
nChars = e ->Sizes[i] / sizeof(cmsUInt16Number);
-
-
+
+
*wcstr = (wchar_t*) _cmsMallocZero(e ->ContextID, (nChars + 1) * sizeof(wchar_t));
if (*wcstr == NULL) return FALSE;
return TRUE;
}
-static
+static
cmsUInt32Number mywcslen(const wchar_t *s)
{
const wchar_t *p;
cmsUInt32Number Before = io ->Tell(io);
cmsUInt32Number n;
- e ->Offsets[i] = Before - BaseOffset;
+ e ->Offsets[i] = Before - BaseOffset;
if (wcstr == NULL) {
e ->Sizes[i] = 0;
n = mywcslen(wcstr);
if (!_cmsWriteWCharArray(io, n, wcstr)) return FALSE;
- e ->Sizes[i] = io ->Tell(io) - Before;
+ e ->Sizes[i] = io ->Tell(io) - Before;
return TRUE;
}
// A way to get null MLUCs
if (e -> Offsets[i] == 0 || e ->Sizes[i] == 0) {
-
+
*mlu = NULL;
return TRUE;
}
{
cmsUInt32Number Before;
- // Special case for undefined strings (see ICC Votable
+ // Special case for undefined strings (see ICC Votable
// Proposal Submission, Dictionary Type and Metadata TAG Definition)
if (mlu == NULL) {
e ->Sizes[i] = 0;
}
Before = io ->Tell(io);
- e ->Offsets[i] = Before - BaseOffset;
+ e ->Offsets[i] = Before - BaseOffset;
if (!Type_MLU_Write(self, io, (void*) mlu, 1)) return FALSE;
- e ->Sizes[i] = io ->Tell(io) - Before;
+ e ->Sizes[i] = io ->Tell(io) - Before;
return TRUE;
}
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
// Get name-value record count
- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
+ if (!_cmsReadUInt32Number(io, &Count)) return NULL;
SizeOfTag -= sizeof(cmsUInt32Number);
- // Get rec lenghth
- if (!_cmsReadUInt32Number(io, &Length)) return NULL;
+ // Get rec lenghth
+ if (!_cmsReadUInt32Number(io, &Length)) return NULL;
SizeOfTag -= sizeof(cmsUInt32Number);
- // Check for valid lengths
+ // Check for valid lengths
if (Length != 16 && Length != 24 && Length != 32) {
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown record length in dictionary '%d'", Length);
return NULL;
}
// Creates an empty dictionary
- hDict = cmsDictAlloc(self -> ContextID);
+ hDict = cmsDictAlloc(self -> ContextID);
if (hDict == NULL) return NULL;
// On depending on record size, create column arrays
if (!ReadOneMLUC(self, io, &a.DisplayValue, i, &DisplayValueMLU)) goto Error;
}
- rc = cmsDictAddEntry(hDict, NameWCS, ValueWCS, DisplayNameMLU, DisplayValueMLU);
+ rc = cmsDictAddEntry(hDict, NameWCS, ValueWCS, DisplayNameMLU, DisplayValueMLU);
if (NameWCS != NULL) _cmsFree(self ->ContextID, NameWCS);
if (ValueWCS != NULL) _cmsFree(self ->ContextID, ValueWCS);
if (!rc) return FALSE;
}
- FreeArray(&a);
+ FreeArray(&a);
*nItems = 1;
- return (void*) hDict;
+ return (void*) hDict;
-Error:
+Error:
FreeArray(&a);
cmsDictFree(hDict);
return NULL;
static
void* Type_Dictionary_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
-{
- return (void*) cmsDictDup((cmsHANDLE) Ptr);
+{
+ return (void*) cmsDictDup((cmsHANDLE) Ptr);
cmsUNUSED_PARAMETER(n);
cmsUNUSED_PARAMETER(self);
static
void Type_Dictionary_Free(struct _cms_typehandler_struct* self, void* Ptr)
{
- cmsDictFree((cmsHANDLE) Ptr);
+ cmsDictFree((cmsHANDLE) Ptr);
cmsUNUSED_PARAMETER(self);
}
{TYPE_HANDLER(cmsCorbisBrokenXYZtype, XYZ), &SupportedTagTypes[27] },
{TYPE_HANDLER(cmsMonacoBrokenCurveType, Curve), &SupportedTagTypes[28] },
{TYPE_HANDLER(cmsSigProfileSequenceIdType, ProfileSequenceId), &SupportedTagTypes[29] },
-{TYPE_HANDLER(cmsSigDictType, Dictionary), &SupportedTagTypes[30] },
+{TYPE_HANDLER(cmsSigDictType, Dictionary), &SupportedTagTypes[30] },
{TYPE_HANDLER(cmsSigVcgtType, vcgt), NULL }
};
#define DEFAULT_TAG_TYPE_COUNT (sizeof(SupportedTagTypes) / sizeof(_cmsTagTypeLinkedList))
-
+
// Both kind of plug-ins share same structure
cmsBool _cmsRegisterTagTypePlugin(cmsPluginBase* Data)
{
{
return GetHandler(sig, SupportedTagTypes);
}
-
+
// ********************************************************************************
// Tag support main routines
// ********************************************************************************
// This is the list of built-in tags
static _cmsTagLinkedList SupportedTags[] = {
- { cmsSigAToB0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[1]},
+ { cmsSigAToB0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[1]},
{ cmsSigAToB1Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[2]},
{ cmsSigAToB2Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[3]},
{ cmsSigBToA0Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[4]},
{ cmsSigBToA1Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[5]},
{ cmsSigBToA2Tag, { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[6]},
-
+
// Allow corbis and its broken XYZ type
{ cmsSigRedColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[7]},
{ cmsSigGreenColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[8]},
{ cmsSigBlueColorantTag, { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[9]},
-
+
{ cmsSigRedTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[10]},
{ cmsSigGreenTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[11]},
- { cmsSigBlueTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[12]},
+ { cmsSigBlueTRCTag, { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[12]},
{ cmsSigCalibrationDateTimeTag, { 1, 1, { cmsSigDateTimeType }, NULL}, &SupportedTags[13]},
{ cmsSigCharTargetTag, { 1, 1, { cmsSigTextType }, NULL}, &SupportedTags[14]},
{ cmsSigMeasurementTag, { 1, 1, { cmsSigMeasurementType }, NULL}, &SupportedTags[39]},
- { cmsSigPs2CRD0Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[40]},
- { cmsSigPs2CRD1Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[41]},
- { cmsSigPs2CRD2Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[42]},
- { cmsSigPs2CRD3Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[43]},
- { cmsSigPs2CSATag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[44]},
- { cmsSigPs2RenderingIntentTag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[45]},
+ { cmsSigPs2CRD0Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[40]},
+ { cmsSigPs2CRD1Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[41]},
+ { cmsSigPs2CRD2Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[42]},
+ { cmsSigPs2CRD3Tag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[43]},
+ { cmsSigPs2CSATag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[44]},
+ { cmsSigPs2RenderingIntentTag, { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[45]},
{ cmsSigViewingCondDescTag, { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[46]},
- { cmsSigUcrBgTag, { 1, 1, { cmsSigUcrBgType}, NULL}, &SupportedTags[47]},
- { cmsSigCrdInfoTag, { 1, 1, { cmsSigCrdInfoType}, NULL}, &SupportedTags[48]},
-
- { cmsSigDToB0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[49]},
- { cmsSigDToB1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[50]},
- { cmsSigDToB2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[51]},
- { cmsSigDToB3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[52]},
- { cmsSigBToD0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[53]},
- { cmsSigBToD1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[54]},
- { cmsSigBToD2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[55]},
- { cmsSigBToD3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[56]},
-
- { cmsSigScreeningDescTag, { 1, 1, { cmsSigTextDescriptionType }, NULL}, &SupportedTags[57]},
- { cmsSigViewingConditionsTag, { 1, 1, { cmsSigViewingConditionsType }, NULL}, &SupportedTags[58]},
-
- { cmsSigScreeningTag, { 1, 1, { cmsSigScreeningType}, NULL }, &SupportedTags[59]},
- { cmsSigVcgtTag, { 1, 1, { cmsSigVcgtType}, NULL }, &SupportedTags[60]},
+ { cmsSigUcrBgTag, { 1, 1, { cmsSigUcrBgType}, NULL}, &SupportedTags[47]},
+ { cmsSigCrdInfoTag, { 1, 1, { cmsSigCrdInfoType}, NULL}, &SupportedTags[48]},
+
+ { cmsSigDToB0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[49]},
+ { cmsSigDToB1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[50]},
+ { cmsSigDToB2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[51]},
+ { cmsSigDToB3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[52]},
+ { cmsSigBToD0Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[53]},
+ { cmsSigBToD1Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[54]},
+ { cmsSigBToD2Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[55]},
+ { cmsSigBToD3Tag, { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[56]},
+
+ { cmsSigScreeningDescTag, { 1, 1, { cmsSigTextDescriptionType }, NULL}, &SupportedTags[57]},
+ { cmsSigViewingConditionsTag, { 1, 1, { cmsSigViewingConditionsType }, NULL}, &SupportedTags[58]},
+
+ { cmsSigScreeningTag, { 1, 1, { cmsSigScreeningType}, NULL }, &SupportedTags[59]},
+ { cmsSigVcgtTag, { 1, 1, { cmsSigVcgtType}, NULL }, &SupportedTags[60]},
{ cmsSigMetaTag, { 1, 1, { cmsSigDictType}, NULL }, &SupportedTags[61]},
- { cmsSigProfileSequenceIdTag, { 1, 1, { cmsSigProfileSequenceIdType}, NULL}, NULL}
+ { cmsSigProfileSequenceIdTag, { 1, 1, { cmsSigProfileSequenceIdType}, NULL}, NULL}
};
/*
Not supported Why
- ======================= =========================================
- cmsSigOutputResponseTag ==> WARNING, POSSIBLE PATENT ON THIS SUBJECT!
- cmsSigNamedColorTag ==> Deprecated
- cmsSigDataTag ==> Ancient, unused
- cmsSigDeviceSettingsTag ==> Deprecated, useless
-*/
+ ======================= =========================================
+ cmsSigOutputResponseTag ==> WARNING, POSSIBLE PATENT ON THIS SUBJECT!
+ cmsSigNamedColorTag ==> Deprecated
+ cmsSigDataTag ==> Ancient, unused
+ cmsSigDeviceSettingsTag ==> Deprecated, useless
+*/
#define DEFAULT_TAG_COUNT (sizeof(SupportedTags) / sizeof(_cmsTagLinkedList))
if (Data == NULL) {
-
+
SupportedTags[DEFAULT_TAG_COUNT-1].Next = NULL;
return TRUE;
}
- pt = Anterior = SupportedTags;
+ pt = Anterior = SupportedTags;
while (pt != NULL) {
if (Plugin->Signature == pt -> Signature) {
pt ->Descriptor = Plugin ->Descriptor; // Replace old behaviour
return TRUE;
- }
+ }
- Anterior = pt;
+ Anterior = pt;
pt = pt ->Next;
}
if (pt == NULL) return FALSE;
pt ->Signature = Plugin ->Signature;
- pt ->Descriptor = Plugin ->Descriptor;
+ pt ->Descriptor = Plugin ->Descriptor;
pt ->Next = NULL;
if (Anterior != NULL) Anterior -> Next = pt;
{
_cmsTagLinkedList* pt;
- for (pt = SupportedTags;
+ for (pt = SupportedTags;
pt != NULL;
pt = pt ->Next) {