From 8385449504700f6ffc9f7efd1c132f5ea42cd2fa Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Mon, 24 Oct 2011 15:51:56 +0200 Subject: Version 2.3, rc 1 --- AUTHORS | 1 + ChangeLog | 5 ++ Projects/BorlandC_5.5/lcms2.rc | 10 ++-- Projects/VC2008/lcms2.rc | 10 ++-- Projects/VC2010/lcms2.rc | 8 +-- configure | 22 +++---- configure.ac | 4 +- doc/LittleCMS2.2 API.pdf | Bin 1088562 -> 0 bytes doc/LittleCMS2.2 Plugin API.pdf | Bin 467007 -> 0 bytes doc/LittleCMS2.2 tutorial.pdf | Bin 708142 -> 0 bytes doc/LittleCMS2.3 API.pdf | Bin 0 -> 1117638 bytes doc/LittleCMS2.3 Plugin API.pdf | Bin 0 -> 487496 bytes doc/LittleCMS2.3 tutorial.pdf | Bin 0 -> 729790 bytes include/lcms2.h | 4 +- src/cmscgats.c | 126 ++++++++++++++++++++-------------------- src/cmserr.c | 8 ++- src/cmsio1.c | 101 ++++++++++++++++++++++++++++++-- src/cmslut.c | 64 ++++++++++++++++++++ src/cmsnamed.c | 9 ++- src/cmspack.c | 6 +- src/lcms2_internal.h | 4 ++ utils/tificc/tificc.c | 6 +- utils/transicc/transicc.c | 2 +- 23 files changed, 283 insertions(+), 107 deletions(-) delete mode 100755 doc/LittleCMS2.2 API.pdf delete mode 100755 doc/LittleCMS2.2 Plugin API.pdf delete mode 100755 doc/LittleCMS2.2 tutorial.pdf create mode 100755 doc/LittleCMS2.3 API.pdf create mode 100755 doc/LittleCMS2.3 Plugin API.pdf create mode 100755 doc/LittleCMS2.3 tutorial.pdf diff --git a/AUTHORS b/AUTHORS index 4e77bf0..d0a338c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,6 +18,7 @@ Robin Watts Shawn Pedersen Andrew Brygin Samuli Suominen +Florian Höch Special Thanks -------------- diff --git a/ChangeLog b/ChangeLog index 88cb615..48dd267 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,3 +46,8 @@ Pascal unit now is supported by Free Pascal Compiler 2.2 Maintenance release ----------------------- +Fixed a 0 byte allocation issue in _cmsCreateSubAllocChunk +Fixed encoding for floating point tags in Lab/XYZ +Fixed Absolute colorimetric intent issues +Fixed a bug on the range of data in transicc, when colorant tag is specified + diff --git a/Projects/BorlandC_5.5/lcms2.rc b/Projects/BorlandC_5.5/lcms2.rc index 4ce60b7..c5e9299 100644 --- a/Projects/BorlandC_5.5/lcms2.rc +++ b/Projects/BorlandC_5.5/lcms2.rc @@ -1,8 +1,8 @@ 1 VERSIONINFO -FILEVERSION 2, 2, 0, 0 -PRODUCTVERSION 2, 2, 0, 0 +FILEVERSION 2, 3, 0, 0 +PRODUCTVERSION 2, 3, 0, 0 FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_DLL { @@ -12,10 +12,10 @@ FILETYPE VFT_DLL { VALUE "CompanyName", "Marti Maria\000\000" VALUE "FileDescription", "lcms color engine\000" - VALUE "FileVersion", "2.01\000\000" - VALUE "InternalName", "lcms\000" + VALUE "FileVersion", "2.03\000\000" + VALUE "InternalName", "lcms2\000" VALUE "LegalCopyright", "Copyright © Marti Maria 2011\000\000" - VALUE "OriginalFilename", "lcms.dll\000" + VALUE "OriginalFilename", "lcms2.dll\000" } } diff --git a/Projects/VC2008/lcms2.rc b/Projects/VC2008/lcms2.rc index 3593fed..d9dc87a 100644 --- a/Projects/VC2008/lcms2.rc +++ b/Projects/VC2008/lcms2.rc @@ -30,8 +30,8 @@ LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN // 1 VERSIONINFO - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,3,0,0 + PRODUCTVERSION 2,3,0,0 FILEFLAGSMASK 0x0L #ifdef _DEBUG FILEFLAGS 0x1L @@ -49,14 +49,14 @@ BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "Marti Maria\0" VALUE "FileDescription", "lcms color engine\0" - VALUE "FileVersion", "2.2\0" + VALUE "FileVersion", "2.3\0" VALUE "InternalName", "lcms\0" - VALUE "LegalCopyright", "Copyright © Marti Maria 2011\0" + VALUE "LegalCopyright", "Copyright (©) Marti Maria 2011\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "lcms2.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "LittleCMS color engine\0" - VALUE "ProductVersion", "2, 0, 2, 0\0" + VALUE "ProductVersion", "2, 0, 3, 0\0" VALUE "SpecialBuild", "\0" END END diff --git a/Projects/VC2010/lcms2.rc b/Projects/VC2010/lcms2.rc index 3593fed..1eb4e04 100644 --- a/Projects/VC2010/lcms2.rc +++ b/Projects/VC2010/lcms2.rc @@ -30,8 +30,8 @@ LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN // 1 VERSIONINFO - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,3,0,0 + PRODUCTVERSION 2,3,0,0 FILEFLAGSMASK 0x0L #ifdef _DEBUG FILEFLAGS 0x1L @@ -49,14 +49,14 @@ BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "Marti Maria\0" VALUE "FileDescription", "lcms color engine\0" - VALUE "FileVersion", "2.2\0" + VALUE "FileVersion", "2.3\0" VALUE "InternalName", "lcms\0" VALUE "LegalCopyright", "Copyright © Marti Maria 2011\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "lcms2.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "LittleCMS color engine\0" - VALUE "ProductVersion", "2, 0, 2, 0\0" + VALUE "ProductVersion", "2, 0, 3, 0\0" VALUE "SpecialBuild", "\0" END END diff --git a/configure b/configure index f8d3eda..7e14486 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for lcms2 2.2. +# Generated by GNU Autoconf 2.68 for lcms2 2.3. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -567,8 +567,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='lcms2' PACKAGE_TARNAME='lcms2' -PACKAGE_VERSION='2.2' -PACKAGE_STRING='lcms2 2.2' +PACKAGE_VERSION='2.3' +PACKAGE_STRING='lcms2 2.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1319,7 +1319,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures lcms2 2.2 to adapt to many kinds of systems. +\`configure' configures lcms2 2.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1389,7 +1389,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of lcms2 2.2:";; + short | recursive ) echo "Configuration of lcms2 2.3:";; esac cat <<\_ACEOF @@ -1498,7 +1498,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -lcms2 configure 2.2 +lcms2 configure 2.3 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1984,7 +1984,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by lcms2 $as_me 2.2, which was +It was created by lcms2 $as_me 2.3, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2355,7 +2355,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # then set age to 0. # LIBRARY_CURRENT=2 -LIBRARY_REVISION=2 +LIBRARY_REVISION=3 LIBRARY_AGE=0 @@ -2899,7 +2899,7 @@ fi # Define the identity of the package. PACKAGE='lcms2' - VERSION='2.2' + VERSION='2.3' # Some tools Automake needs. @@ -17248,7 +17248,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by lcms2 $as_me 2.2, which was +This file was extended by lcms2 $as_me 2.3, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -17305,7 +17305,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -lcms2 config.status 2.2 +lcms2 config.status 2.3 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index f97c3c5..8e0b2b8 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREREQ(2.60) # # Set the package name and version # -AC_INIT(lcms2,2.2) +AC_INIT(lcms2,2.3) # # Libtool library revision control info @@ -31,7 +31,7 @@ AC_INIT(lcms2,2.2) # then set age to 0. # LIBRARY_CURRENT=2 -LIBRARY_REVISION=2 +LIBRARY_REVISION=3 LIBRARY_AGE=0 AC_SUBST(LIBRARY_CURRENT)dnl diff --git a/doc/LittleCMS2.2 API.pdf b/doc/LittleCMS2.2 API.pdf deleted file mode 100755 index 8129f4a..0000000 Binary files a/doc/LittleCMS2.2 API.pdf and /dev/null differ diff --git a/doc/LittleCMS2.2 Plugin API.pdf b/doc/LittleCMS2.2 Plugin API.pdf deleted file mode 100755 index 0b0b5c4..0000000 Binary files a/doc/LittleCMS2.2 Plugin API.pdf and /dev/null differ diff --git a/doc/LittleCMS2.2 tutorial.pdf b/doc/LittleCMS2.2 tutorial.pdf deleted file mode 100755 index 86514ba..0000000 Binary files a/doc/LittleCMS2.2 tutorial.pdf and /dev/null differ diff --git a/doc/LittleCMS2.3 API.pdf b/doc/LittleCMS2.3 API.pdf new file mode 100755 index 0000000..8e12e70 Binary files /dev/null and b/doc/LittleCMS2.3 API.pdf differ diff --git a/doc/LittleCMS2.3 Plugin API.pdf b/doc/LittleCMS2.3 Plugin API.pdf new file mode 100755 index 0000000..194e4f8 Binary files /dev/null and b/doc/LittleCMS2.3 Plugin API.pdf differ diff --git a/doc/LittleCMS2.3 tutorial.pdf b/doc/LittleCMS2.3 tutorial.pdf new file mode 100755 index 0000000..1bdfc7a Binary files /dev/null and b/doc/LittleCMS2.3 tutorial.pdf differ diff --git a/include/lcms2.h b/include/lcms2.h index 95da011..6ef2815 100644 --- a/include/lcms2.h +++ b/include/lcms2.h @@ -23,7 +23,7 @@ // //--------------------------------------------------------------------------------- // -// Version 2.2 +// Version 2.3 // #ifndef _lcms2_H @@ -69,7 +69,7 @@ extern "C" { #endif // Version/release -#define LCMS_VERSION 2020 +#define LCMS_VERSION 2030 // I will give the chance of redefining basic types for compilers that are not fully C99 compliant #ifndef CMS_BASIC_TYPES_ALREADY_DEFINED diff --git a/src/cmscgats.c b/src/cmscgats.c index d954056..e5124ec 100644 --- a/src/cmscgats.c +++ b/src/cmscgats.c @@ -2151,7 +2151,7 @@ cmsBool IsMyFile(const char* FileName) Size = (cmsUInt32Number) fread(Ptr, 1, 132, fp); if (fclose(fp) != 0) - return FALSE; + return FALSE; Ptr[Size] = '\0'; @@ -2165,10 +2165,10 @@ cmsHANDLE CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, void *Ptr, cmsUInt3 { cmsHANDLE hIT8; cmsIT8* it8; - int type; + int type; - _cmsAssert(Ptr != NULL); - _cmsAssert(len != 0); + _cmsAssert(Ptr != NULL); + _cmsAssert(len != 0); type = IsMyBlock((cmsUInt8Number*)Ptr, len); if (type == 0) return NULL; @@ -2208,11 +2208,11 @@ cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileN cmsHANDLE hIT8; cmsIT8* it8; - int type; - - _cmsAssert(cFileName != NULL); + int type; + + _cmsAssert(cFileName != NULL); - type = IsMyFile(cFileName); + type = IsMyFile(cFileName); if (type == 0) return NULL; hIT8 = cmsIT8Alloc(ContextID); @@ -2241,10 +2241,10 @@ cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileN CookPointers(it8); it8 ->nTable = 0; - if (fclose(it8 ->FileStack[0]->Stream)!= 0) { - cmsIT8Free(hIT8); + if (fclose(it8 ->FileStack[0]->Stream)!= 0) { + cmsIT8Free(hIT8); return NULL; - } + } return hIT8; @@ -2252,16 +2252,16 @@ cmsHANDLE CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileN int CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames) { - cmsIT8* it8 = (cmsIT8*) hIT8; - TABLE* t; + cmsIT8* it8 = (cmsIT8*) hIT8; + TABLE* t; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); - t = GetTable(it8); + t = GetTable(it8); - if (SampleNames) - *SampleNames = t -> DataFormat; - return t -> nSamples; + if (SampleNames) + *SampleNames = t -> DataFormat; + return t -> nSamples; } @@ -2272,10 +2272,10 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyN cmsUInt32Number n; char **Props; TABLE* t; - - _cmsAssert(hIT8 != NULL); + + _cmsAssert(hIT8 != NULL); - t = GetTable(it8); + t = GetTable(it8); // Pass#1 - count properties @@ -2304,11 +2304,11 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cP cmsUInt32Number n; const char **Props; TABLE* t; - - _cmsAssert(hIT8 != NULL); + + _cmsAssert(hIT8 != NULL); - t = GetTable(it8); + t = GetTable(it8); if(!IsAvailableOnList(t->HeaderList, cProp, NULL, &p)) { *SubpropertyNames = 0; @@ -2402,7 +2402,7 @@ int CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample) { cmsIT8* it8 = (cmsIT8*) hIT8; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); return LocateSample(it8, cSample); } @@ -2413,7 +2413,7 @@ const char* CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col) { cmsIT8* it8 = (cmsIT8*) hIT8; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); return GetData(it8, row, col); } @@ -2439,7 +2439,7 @@ cmsBool CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col, const ch { cmsIT8* it8 = (cmsIT8*) hIT8; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); return SetData(it8, row, col, Val); } @@ -2450,7 +2450,7 @@ cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col, cmsFl cmsIT8* it8 = (cmsIT8*) hIT8; char Buff[256]; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); sprintf(Buff, it8->DoubleFormatter, Val); @@ -2464,7 +2464,7 @@ const char* CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const ch cmsIT8* it8 = (cmsIT8*) hIT8; int iField, iSet; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); iField = LocateSample(it8, cSample); if (iField < 0) { @@ -2503,10 +2503,10 @@ cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch, const char* cmsIT8* it8 = (cmsIT8*) hIT8; int iField, iSet; TABLE* t; - - _cmsAssert(hIT8 != NULL); + + _cmsAssert(hIT8 != NULL); - t = GetTable(it8); + t = GetTable(it8); iField = LocateSample(it8, cSample); @@ -2541,53 +2541,53 @@ cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch, const char* cmsBool CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch, - const char* cSample, - cmsFloat64Number Val) + const char* cSample, + cmsFloat64Number Val) { - cmsIT8* it8 = (cmsIT8*) hIT8; - char Buff[256]; + cmsIT8* it8 = (cmsIT8*) hIT8; + char Buff[256]; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); - snprintf(Buff, 255, it8->DoubleFormatter, Val); - return cmsIT8SetData(hIT8, cPatch, cSample, Buff); + snprintf(Buff, 255, it8->DoubleFormatter, Val); + return cmsIT8SetData(hIT8, cPatch, cSample, Buff); } // Buffer should get MAXSTR at least const char* CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer) { - cmsIT8* it8 = (cmsIT8*) hIT8; - TABLE* t; - char* Data; + cmsIT8* it8 = (cmsIT8*) hIT8; + TABLE* t; + char* Data; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); - t = GetTable(it8); - Data = GetData(it8, nPatch, t->SampleID); + t = GetTable(it8); + Data = GetData(it8, nPatch, t->SampleID); - if (!Data) return NULL; - if (!buffer) return Data; + if (!Data) return NULL; + if (!buffer) return Data; - strncpy(buffer, Data, MAXSTR-1); - buffer[MAXSTR-1] = 0; - return buffer; + strncpy(buffer, Data, MAXSTR-1); + buffer[MAXSTR-1] = 0; + return buffer; } int CMSEXPORT cmsIT8GetPatchByName(cmsHANDLE hIT8, const char *cPatch) { - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); return LocatePatch((cmsIT8*)hIT8, cPatch); } cmsUInt32Number CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8) { - cmsIT8* it8 = (cmsIT8*) hIT8; + cmsIT8* it8 = (cmsIT8*) hIT8; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); - return it8 ->TablesCount; + return it8 ->TablesCount; } // This handles the "LABEL" extension. @@ -2627,17 +2627,17 @@ int CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char cmsBool CMSEXPORT cmsIT8SetIndexColumn(cmsHANDLE hIT8, const char* cSample) { - cmsIT8* it8 = (cmsIT8*) hIT8; - int pos; + cmsIT8* it8 = (cmsIT8*) hIT8; + int pos; - _cmsAssert(hIT8 != NULL); + _cmsAssert(hIT8 != NULL); - pos = LocateSample(it8, cSample); - if(pos == -1) - return FALSE; + pos = LocateSample(it8, cSample); + if(pos == -1) + return FALSE; - it8->Tab[it8->nTable].SampleID = pos; - return TRUE; + it8->Tab[it8->nTable].SampleID = pos; + return TRUE; } @@ -2651,5 +2651,7 @@ void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter) strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT); else strcpy(it8->DoubleFormatter, Formatter); + + it8 ->DoubleFormatter[sizeof(it8 ->DoubleFormatter)-1] = 0; } diff --git a/src/cmserr.c b/src/cmserr.c index 83d1e4f..bfd2bd0 100644 --- a/src/cmserr.c +++ b/src/cmserr.c @@ -256,6 +256,10 @@ _cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32N { _cmsSubAllocator_chunk* chunk; + // 20K by default + if (Initial == 0) + Initial = 20*1024; + // Create the container chunk = (_cmsSubAllocator_chunk*) _cmsMallocZero(ContextID, sizeof(_cmsSubAllocator_chunk)); if (chunk == NULL) return NULL; @@ -269,9 +273,7 @@ _cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32N return NULL; } - // 20K by default - if (Initial == 0) - Initial = 20*1024; + chunk ->BlockSize = Initial; chunk ->Used = 0; diff --git a/src/cmsio1.c b/src/cmsio1.c index ea92567..0787503 100644 --- a/src/cmsio1.c +++ b/src/cmsio1.c @@ -237,6 +237,34 @@ cmsPipeline* BuildRGBInputMatrixShaper(cmsHPROFILE hProfile) return Lut; } + + +// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded +static +cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) +{ + cmsContext ContextID = cmsGetProfileContextID(hProfile); + cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile); + + if (Lut == NULL) return NULL; + + // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding, + // and since the formatter has already accomodated to 0..1.0, we should undo this change + if ( spc == cmsSigLabData) + { + cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)); + } + else + if (spc == cmsSigXYZData) + { + cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)); + } + + return Lut; +} + + // Read and create a BRAND NEW MPE LUT from a given profile. All stuff dependent of version, etc // is adjusted here in order to create a LUT that takes care of all those details cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent) @@ -267,8 +295,9 @@ cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent) if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence - // Floating point LUT are always V4, so no adjustment is required - return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + // Floating point LUT are always V4, but the encoding range is no + // longer 0..1.0, so we need to add an stage depending on the color space + return _cmsReadFloatInputTag(hProfile, tagFloat); } // Revert to perceptual if no tag is found @@ -430,6 +459,32 @@ void ChangeInterpolationToTrilinear(cmsPipeline* Lut) } } + +// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded +static +cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) +{ + cmsContext ContextID = cmsGetProfileContextID(hProfile); + cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + cmsColorSpaceSignature PCS = cmsGetPCS(hProfile); + + if (Lut == NULL) return NULL; + + // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding, + // and since the formatter has already accomodated to 0..1.0, we should undo this change + if ( PCS == cmsSigLabData) + { + cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)); + } + else + if (PCS == cmsSigXYZData) + { + cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)); + } + + return Lut; +} + // Create an output MPE LUT from agiven profile. Version mismatches are handled here cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent) { @@ -440,8 +495,8 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent) if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence - // Floating point LUT are always V4, so no adjustment is required - return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + // Floating point LUT are always V4 + return _cmsReadFloatOutputTag(hProfile, tagFloat); } // Revert to perceptual if no tag is found @@ -499,6 +554,40 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent) // --------------------------------------------------------------------------------------------------------------- +// Read the AToD0 tag, adjusting the encoding of Lab or XYZ if neded +static +cmsPipeline* _cmsReadFloatDevicelinkTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) +{ + cmsContext ContextID = cmsGetProfileContextID(hProfile); + cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + cmsColorSpaceSignature PCS = cmsGetPCS(hProfile); + cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile); + + if (Lut == NULL) return NULL; + + if (spc == cmsSigLabData) + { + cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)); + } + else + if (spc == cmsSigXYZData) + { + cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)); + } + + if (PCS == cmsSigLabData) + { + cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)); + } + else + if (PCS == cmsSigXYZData) + { + cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)); + } + + return Lut; +} + // This one includes abstract profiles as well. Matrix-shaper cannot be obtained on that device class. The // tag name here may default to AToB0 cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent) @@ -531,8 +620,8 @@ cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent) if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence - // Floating point LUT are always V4, no adjustment is required - return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); + // Floating point LUT are always V + return _cmsReadFloatDevicelinkTag(hProfile, tagFloat); } tagFloat = Device2PCSFloat[0]; diff --git a/src/cmslut.c b/src/cmslut.c index aaad3b4..52204be 100644 --- a/src/cmslut.c +++ b/src/cmslut.c @@ -1018,6 +1018,70 @@ cmsStage* _cmsStageAllocLabV4ToV2(cmsContext ContextID) } +// To Lab to float. Note that the MPE gives numbers in normal Lab range +// and we need 0..1.0 range for the formatters +// L* : 0...100 => 0...1.0 (L* / 100) +// ab* : -128..+127 to 0..1 ((ab* + 128) / 255) + +cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID) +{ + static const cmsFloat64Number a1[] = { + 1.0/100.0, 0, 0, + 0, 1.0/255.0, 0, + 0, 0, 1.0/255.0 + }; + + static const cmsFloat64Number o1[] = { + 0, + 128.0/255.0, + 128.0/255.0 + }; + + return cmsStageAllocMatrix(ContextID, 3, 3, a1, o1); +} + +cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID) +{ + static const cmsFloat64Number a1[] = { + 1.0/100.0, 0, 0, + 0, 1.0/100.0, 0, + 0, 0, 1.0/100.0 + }; + + + return cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL); +} + +cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID) +{ + static const cmsFloat64Number a1[] = { + 100.0, 0, 0, + 0, 255.0, 0, + 0, 0, 255.0 + }; + + static const cmsFloat64Number o1[] = { + 0, + -128.0, + -128.0 + }; + + return cmsStageAllocMatrix(ContextID, 3, 3, a1, o1); +} + +cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID) +{ + static const cmsFloat64Number a1[] = { + 100.0, 0, 0, + 0, 100.0, 0, + 0, 0, 100.0 + }; + + return cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL); +} + + + // ******************************************************************************** // Type cmsSigXYZ2LabElemType // ******************************************************************************** diff --git a/src/cmsnamed.c b/src/cmsnamed.c index 1bcde4a..28ff45d 100644 --- a/src/cmsnamed.c +++ b/src/cmsnamed.c @@ -490,6 +490,8 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)); strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)); + v->Prefix[32] = v->Suffix[32] = 0; + v -> ColorantCount = ColorantCount; return v; @@ -543,9 +545,14 @@ cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList, for (i=0; i < 3; i++) NamedColorList ->List[NamedColorList ->nColors].PCS[i] = PCS == NULL ? 0 : PCS[i]; - if (Name != NULL) + if (Name != NULL) { + strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, sizeof(NamedColorList ->List[NamedColorList ->nColors].Name)); + + NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0; + + } else NamedColorList ->List[NamedColorList ->nColors].Name[0] = 0; diff --git a/src/cmspack.c b/src/cmspack.c index 79a854e..63a9bc0 100644 --- a/src/cmspack.c +++ b/src/cmspack.c @@ -983,7 +983,7 @@ cmsUInt8Number* UnrollLabDoubleToFloat(_cmsTRANSFORM* info, } else { - wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 + wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0); // form -128..+127 to 0..1 wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0); @@ -1003,7 +1003,7 @@ cmsUInt8Number* UnrollLabFloatToFloat(_cmsTRANSFORM* info, if (T_PLANAR(info -> InputFormat)) { - wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 + wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 wIn[1] = (cmsFloat32Number) ((Pt[Stride] + 128) / 255.0); // form -128..+127 to 0..1 wIn[2] = (cmsFloat32Number) ((Pt[Stride*2] + 128) / 255.0); @@ -1011,7 +1011,7 @@ cmsUInt8Number* UnrollLabFloatToFloat(_cmsTRANSFORM* info, } else { - wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 + wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0); // from 0..100 to 0..1 wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0); // form -128..+127 to 0..1 wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0); diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h index 872272a..b40f301 100644 --- a/src/lcms2_internal.h +++ b/src/lcms2_internal.h @@ -427,6 +427,10 @@ cmsStage* _cmsStageAllocLabV4ToV2(cmsContext ContextID); cmsStage* _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsBool UsePCS); cmsStage* _cmsStageAllocIdentityCurves(cmsContext ContextID, int nChannels); cmsStage* _cmsStageAllocIdentityCLut(cmsContext ContextID, int nChan); +cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID); +cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID); +cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID); +cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID); // For curve set only cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe); diff --git a/utils/tificc/tificc.c b/utils/tificc/tificc.c index a36612d..16a979f 100644 --- a/utils/tificc/tificc.c +++ b/utils/tificc/tificc.c @@ -77,8 +77,10 @@ void ConsoleErrorHandler(const char* module, const char* fmt, va_list ap) { char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ": "); + if (module != NULL) { + if (strlen(module) < 500) + strcat(strcpy(e, module), ": "); + } vsprintf(e+strlen(e), fmt, ap); strcat(e, "."); diff --git a/utils/transicc/transicc.c b/utils/transicc/transicc.c index a670b7b..2181359 100644 --- a/utils/transicc/transicc.c +++ b/utils/transicc/transicc.c @@ -462,7 +462,7 @@ cmsBool OpenTransforms(void) if (cmsNamedColorCount(InputColorant) <= 3) SetRange(255, TRUE); else - SetRange(100, TRUE); + SetRange(1, TRUE); // Inks are already divided by 100 in the formatter } else InputColorant = ComponentNames(InputColorSpace, TRUE); -- cgit v1.2.1