< prev index next >

src/java.desktop/share/native/liblcms/cmstypes.c

Print this page

        

*** 28,38 **** // file: // //--------------------------------------------------------------------------------- // // Little Color Management System ! // Copyright (c) 1998-2017 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, --- 28,38 ---- // file: // //--------------------------------------------------------------------------------- // // Little Color Management System ! // Copyright (c) 1998-2020 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,
*** 193,203 **** void* Cargo, cmsUInt32Number n, cmsUInt32Number SizeOfTag); // Helper function to deal with position tables as described 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, --- 193,203 ---- void* Cargo, cmsUInt32Number n, cmsUInt32Number SizeOfTag); // Helper function to deal with position tables as described in ICC spec 4.3 ! // A table of n elements is read, 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,
*** 1001,1011 **** // Get the len of string len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0); // Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data ! //(see clause 4.1 for the definition of “aligned”). 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. --- 1001,1011 ---- // Get the len of string len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0); // Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data ! //(see clause 4.1 for the definition of 'aligned'). 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.
*** 1507,1517 **** if (((Offset + Len) < Len) || ((Offset + Len) > SizeOfTag + 8)) goto Error; // 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].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number); // To guess maximum size, add offset + len EndOfThisString = BeginOfThisString + Len; --- 1507,1517 ---- if (((Offset + Len) < Len) || ((Offset + Len) > SizeOfTag + 8)) goto Error; // True begin of the string BeginOfThisString = Offset - SizeOfHeader - 8; ! // Adjust to wchar_t elements 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 EndOfThisString = BeginOfThisString + Len;
*** 1880,1890 **** // We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin. static cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { ! cmsUInt32Number j, nTabSize; cmsUInt8Number val; cmsPipeline* NewLUT = (cmsPipeline*) Ptr; cmsStage* mpe; _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL; _cmsStageMatrixData* MatMPE = NULL; --- 1880,1890 ---- // We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin. static cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { ! cmsUInt32Number j, nTabSize, i, n; cmsUInt8Number val; cmsPipeline* NewLUT = (cmsPipeline*) Ptr; cmsStage* mpe; _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL; _cmsStageMatrixData* MatMPE = NULL;
*** 1929,1954 **** if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->InputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->OutputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding 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 (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE; ! } else { if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; --- 1929,1951 ---- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->InputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->OutputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding + n = NewLUT->InputChannels * NewLUT->OutputChannels; if (MatMPE != NULL) { ! for (i = 0; i < n; i++) ! { ! if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; ! } } else { + if (n != 9) return FALSE; + if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
*** 2183,2192 **** --- 2180,2190 ---- // Disassemble the LUT into components. mpe = NewLUT -> Elements; if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) { MatMPE = (_cmsStageMatrixData*) mpe ->Data; + if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE; mpe = mpe -> Next; } if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
*** 2221,2242 **** if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding - 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 (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE; } else { if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; --- 2219,2235 ---- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE; if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding if (MatMPE != NULL) { ! for (i = 0; i < 9; i++) ! { ! if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; ! } ! } else { if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
*** 2577,2610 **** // 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 ! if (!_cmsWrite15Fixed16Number(io, m -> Double[0])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[1])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[2])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[3])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[4])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[5])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[6])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[7])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Double[8])) return FALSE; ! ! if (m ->Offset != NULL) { ! ! if (!_cmsWrite15Fixed16Number(io, m -> Offset[0])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Offset[1])) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, m -> Offset[2])) return FALSE; } else { if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; ! if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; ! } return TRUE; --- 2570,2603 ---- // Write a set of curves static cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe) { + cmsUInt32Number i, n; + _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data; + n = mpe->InputChannels * mpe->OutputChannels; + // Write the Matrix ! for (i = 0; i < n; i++) ! { ! if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE; ! } ! ! if (m->Offset != NULL) { ! ! for (i = 0; i < mpe->OutputChannels; i++) ! { ! if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE; ! } } else { + for (i = 0; i < mpe->OutputChannels; i++) + { if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; ! } } return TRUE;
*** 3118,3131 **** // ******************************************************************************** // //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’s “color space of data” field. ! //This representation should be consistent with the “number of device components” //field in the namedColor2Type. If this field is 0, device coordinates are not provided. ! //The PCS representation corresponds to the header’s 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 --- 3111,3124 ---- // ******************************************************************************** // //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's 'color space of data' field. ! //This representation should be consistent with the 'number of device components' //field in the namedColor2Type. If this field is 0, device coordinates are not provided. ! //The PCS representation corresponds to the header's 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
*** 3866,3876 **** // ******************************************************************************** // Type cmsSigViewingConditionsType // ******************************************************************************** // //This type represents a set of viewing condition parameters including: ! //CIE ’absolute’ illuminant white point tristimulus values and CIE ’absolute’ //surround tristimulus values. static void *Type_ViewingConditions_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { --- 3859,3869 ---- // ******************************************************************************** // Type cmsSigViewingConditionsType // ******************************************************************************** // //This type represents a set of viewing condition parameters including: ! //CIE 'absolute' illuminant white point tristimulus values and CIE 'absolute' //surround tristimulus values. static void *Type_ViewingConditions_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) {
*** 3953,3963 **** cmsUNUSED_PARAMETER(self); } // Each curve is stored in one or more curve segments, with break-points specified between curve segments. ! // The first curve segment always starts at –Infinity, and the last curve segment always ends at +Infinity. The // first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be // specified either in terms of a formula, or by a sampled curve. // Read an embedded segmented curve --- 3946,3956 ---- cmsUNUSED_PARAMETER(self); } // Each curve is stored in one or more curve segments, with break-points specified between curve segments. ! // The first curve segment always starts at -Infinity, and the last curve segment always ends at +Infinity. The // first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be // specified either in terms of a formula, or by a sampled curve. // Read an embedded segmented curve
*** 4234,4244 **** // The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the // matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array // is organized as follows: ! // array = [e11, e12, …, e1P, e21, e22, …, e2P, …, eQ1, eQ2, …, eQP, e1, e2, …, eQ] static void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { cmsStage* mpe; --- 4227,4237 ---- // The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the // matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array // is organized as follows: ! // array = [e11, e12, ..., e1P, e21, e22, ..., e2P, ..., eQ1, eQ2, ..., eQP, e1, e2, ..., eQ] static void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { cmsStage* mpe;
*** 4757,4770 **** // Parametric curve type 5 is: // Y = (aX + b)^Gamma + e | X >= d // Y = cX + f | X < d // vcgt formula is: ! // Y = (Max – Min) * (X ^ Gamma) + Min // So, the translation is ! // a = (Max – Min) ^ ( 1 / Gamma) // e = Min // b=c=d=f=0 Params[0] = Colorant[n].Gamma; Params[1] = pow((Colorant[n].Max - Colorant[n].Min), (1.0 / Colorant[n].Gamma)); --- 4750,4763 ---- // Parametric curve type 5 is: // Y = (aX + b)^Gamma + e | X >= d // Y = cX + f | X < d // vcgt formula is: ! // Y = (Max - Min) * (X ^ Gamma) + Min // So, the translation is ! // a = (Max - Min) ^ ( 1 / Gamma) // e = Min // b=c=d=f=0 Params[0] = Colorant[n].Gamma; Params[1] = pow((Colorant[n].Max - Colorant[n].Min), (1.0 / Colorant[n].Gamma));
< prev index next >