mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-27 22:02:25 +00:00
8375065: Update LCMS to 2.18
Reviewed-by: prr, serb, jdv
This commit is contained in:
parent
3065aa48c9
commit
3871b8899d
@ -1,11 +1,11 @@
|
||||
## Little Color Management System (LCMS) v2.17
|
||||
## Little Color Management System (LCMS) v2.18
|
||||
|
||||
### LCMS License
|
||||
<pre>
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (C) 1998-2025 Marti Maria Saguer
|
||||
Copyright (C) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -406,7 +406,7 @@ int FormatterPos(cmsUInt32Number frm)
|
||||
static
|
||||
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
|
||||
{
|
||||
static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
|
||||
static const cmsFormatterAlphaFn FormattersAlpha[6][6] = {
|
||||
|
||||
/* from 8 */ { copy8, from8to16, from8to16SE, from8toHLF, from8toFLT, from8toDBL },
|
||||
/* from 16*/ { from16to8, copy16, from16to16, from16toHLF, from16toFLT, from16toDBL },
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -285,27 +285,32 @@ CAM02COLOR InverseCorrelates(CAM02COLOR clr, cmsCIECAM02* pMod)
|
||||
(clr.J / 100.0),
|
||||
(1.0 / (pMod->c * pMod->z)));
|
||||
|
||||
p1 = e / t;
|
||||
p2 = (clr.A / pMod->Nbb) + 0.305;
|
||||
p3 = 21.0 / 20.0;
|
||||
|
||||
hr = clr.h * d2r;
|
||||
|
||||
if (fabs(sin(hr)) >= fabs(cos(hr))) {
|
||||
p4 = p1 / sin(hr);
|
||||
clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
|
||||
(p4 + (2.0 + p3) * (220.0 / 1403.0) *
|
||||
(cos(hr) / sin(hr)) - (27.0 / 1403.0) +
|
||||
p3 * (6300.0 / 1403.0));
|
||||
clr.a = clr.b * (cos(hr) / sin(hr));
|
||||
if ( t <= 0.0 ) { // special case from spec notes, avoid divide by zero
|
||||
clr.a = clr.b = 0.0;
|
||||
}
|
||||
else {
|
||||
p5 = p1 / cos(hr);
|
||||
clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
|
||||
(p5 + (2.0 + p3) * (220.0 / 1403.0) -
|
||||
((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
|
||||
(sin(hr) / cos(hr)));
|
||||
clr.b = clr.a * (sin(hr) / cos(hr));
|
||||
hr = clr.h * d2r;
|
||||
p1 = e / t;
|
||||
p3 = 21.0 / 20.0;
|
||||
|
||||
if (fabs(sin(hr)) >= fabs(cos(hr))) {
|
||||
p4 = p1 / sin(hr);
|
||||
clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
|
||||
(p4 + (2.0 + p3) * (220.0 / 1403.0) *
|
||||
(cos(hr) / sin(hr)) - (27.0 / 1403.0) +
|
||||
p3 * (6300.0 / 1403.0));
|
||||
clr.a = clr.b * (cos(hr) / sin(hr));
|
||||
}
|
||||
else {
|
||||
p5 = p1 / cos(hr);
|
||||
clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
|
||||
(p5 + (2.0 + p3) * (220.0 / 1403.0) -
|
||||
((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
|
||||
(sin(hr) / cos(hr)));
|
||||
clr.b = clr.a * (sin(hr) / cos(hr));
|
||||
}
|
||||
}
|
||||
|
||||
clr.RGBpa[0] = ((460.0 / 1403.0) * p2) +
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -295,7 +295,7 @@ typedef struct {
|
||||
WRITEMODE as; // How is supposed to be written
|
||||
} PROPERTY;
|
||||
|
||||
static PROPERTY PredefinedProperties[] = {
|
||||
static const PROPERTY PredefinedProperties[] = {
|
||||
|
||||
{"NUMBER_OF_FIELDS", WRITE_UNCOOKED}, // Required - NUMBER OF FIELDS
|
||||
{"NUMBER_OF_SETS", WRITE_UNCOOKED}, // Required - NUMBER OF SETS
|
||||
@ -458,7 +458,7 @@ cmsBool StringAppend(string* s, char c)
|
||||
new_ptr = (char*) AllocChunk(s->it8, s->max);
|
||||
if (new_ptr == NULL) return FALSE;
|
||||
|
||||
if (new_ptr != NULL && s->begin != NULL)
|
||||
if (s->begin != NULL)
|
||||
memcpy(new_ptr, s->begin, s->len);
|
||||
|
||||
s->begin = new_ptr;
|
||||
@ -899,6 +899,11 @@ void InSymbol(cmsIT8* it8)
|
||||
sign = -1;
|
||||
NextCh(it8);
|
||||
}
|
||||
else
|
||||
if (it8->ch == '+') {
|
||||
sign = +1;
|
||||
NextCh(it8);
|
||||
}
|
||||
|
||||
it8->inum = 0;
|
||||
it8->sy = SINUM;
|
||||
@ -3206,7 +3211,7 @@ cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[]
|
||||
|
||||
int nodes = lut_size * lut_size * lut_size;
|
||||
|
||||
cmsFloat32Number* lut_table = _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
|
||||
cmsFloat32Number* lut_table = (cmsFloat32Number*) _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
|
||||
if (lut_table == NULL) return FALSE;
|
||||
|
||||
for (i = 0; i < nodes; i++) {
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -1187,6 +1187,7 @@ cmsBool smooth2(cmsContext ContextID, cmsFloat32Number w[], cmsFloat32Number y[]
|
||||
cmsFloat32Number *c, *d, *e;
|
||||
cmsBool st;
|
||||
|
||||
if (m < 4 || lambda < MATRIX_DET_TOLERANCE) return FALSE;
|
||||
|
||||
c = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
|
||||
d = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -984,9 +984,9 @@ void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
c1 = c2 = c3 = 0;
|
||||
}
|
||||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
|
||||
|
||||
Tmp1[OutChan] = (cmsUInt16Number)(c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
Tmp1[OutChan] = (cmsUInt16Number)c0 + ((Rest + (Rest >> 16)) >> 16);
|
||||
}
|
||||
|
||||
|
||||
@ -1048,9 +1048,9 @@ void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
c1 = c2 = c3 = 0;
|
||||
}
|
||||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
|
||||
|
||||
Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
Tmp2[OutChan] = (cmsUInt16Number) c0 + ((Rest + (Rest >> 16)) >> 16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -685,6 +685,7 @@ void _cmsDeleteTagByPos(_cmsICCPROFILE* Icc, int i)
|
||||
// Free previous version
|
||||
if (Icc ->TagSaveAsRaw[i]) {
|
||||
_cmsFree(Icc ->ContextID, Icc ->TagPtrs[i]);
|
||||
Icc->TagSaveAsRaw[i] = FALSE;
|
||||
}
|
||||
else {
|
||||
cmsTagTypeHandler* TypeHandler = Icc ->TagTypeHandlers[i];
|
||||
@ -1605,6 +1606,8 @@ void freeOneTag(_cmsICCPROFILE* Icc, cmsUInt32Number i)
|
||||
else
|
||||
_cmsFree(Icc->ContextID, Icc->TagPtrs[i]);
|
||||
}
|
||||
|
||||
Icc->TagPtrs[i] = NULL;
|
||||
}
|
||||
|
||||
// Closes a profile freeing any involved resources
|
||||
@ -1847,8 +1850,11 @@ cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const v
|
||||
|
||||
if (!_cmsNewTag(Icc, sig, &i)) goto Error;
|
||||
|
||||
// This is not raw
|
||||
Icc ->TagSaveAsRaw[i] = FALSE;
|
||||
// This cannot be RAW
|
||||
if (Icc->TagSaveAsRaw[i]) {
|
||||
cmsSignalError(Icc->ContextID, cmsERROR_ALREADY_DEFINED, "Tag '%x' was already saved as RAW", sig);
|
||||
goto Error;
|
||||
}
|
||||
|
||||
// This is not a link
|
||||
Icc ->TagLinked[i] = (cmsTagSignature) 0;
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -1012,7 +1012,13 @@ const cmsMLU* GetInfo(cmsHPROFILE hProfile, cmsInfoType Info)
|
||||
switch (Info) {
|
||||
|
||||
case cmsInfoDescription:
|
||||
sig = cmsSigProfileDescriptionTag;
|
||||
/**
|
||||
* Add for MacOS, which uses propiertary tags for description
|
||||
*/
|
||||
if (cmsIsTag(hProfile, cmsSigProfileDescriptionMLTag))
|
||||
sig = cmsSigProfileDescriptionMLTag;
|
||||
else
|
||||
sig = cmsSigProfileDescriptionTag;
|
||||
break;
|
||||
|
||||
case cmsInfoManufacturer:
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -303,7 +303,7 @@ cmsUInt32Number encodeUTF8(char* out, const wchar_t* in, cmsUInt32Number max_wch
|
||||
cmsUInt32Number size = 0;
|
||||
cmsUInt32Number len_w = 0;
|
||||
|
||||
while (*in && len_w < max_wchars)
|
||||
while (len_w < max_wchars && *in)
|
||||
{
|
||||
if (*in >= 0xd800 && *in <= 0xdbff)
|
||||
codepoint = ((*in - 0xd800) << 10) + 0x10000;
|
||||
@ -1071,17 +1071,17 @@ cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq)
|
||||
if (pseq == NULL)
|
||||
return NULL;
|
||||
|
||||
NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ));
|
||||
NewSeq = (cmsSEQ*)_cmsMallocZero(pseq->ContextID, sizeof(cmsSEQ));
|
||||
if (NewSeq == NULL) return NULL;
|
||||
|
||||
NewSeq->ContextID = pseq->ContextID;
|
||||
|
||||
NewSeq -> seq = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC));
|
||||
if (NewSeq ->seq == NULL) goto Error;
|
||||
NewSeq->seq = (cmsPSEQDESC*)_cmsCalloc(pseq->ContextID, pseq->n, sizeof(cmsPSEQDESC));
|
||||
if (NewSeq->seq == NULL) goto Error;
|
||||
|
||||
NewSeq -> ContextID = pseq ->ContextID;
|
||||
NewSeq -> n = pseq ->n;
|
||||
NewSeq->n = pseq->n;
|
||||
|
||||
for (i=0; i < pseq->n; i++) {
|
||||
for (i = 0; i < pseq->n; i++) {
|
||||
|
||||
memmove(&NewSeq ->seq[i].attributes, &pseq ->seq[i].attributes, sizeof(cmsUInt64Number));
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -698,11 +698,16 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
||||
if (ColorSpace == (cmsColorSpaceSignature)0 ||
|
||||
OutputColorSpace == (cmsColorSpaceSignature)0) return FALSE;
|
||||
|
||||
nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags);
|
||||
|
||||
// For empty LUTs, 2 points are enough
|
||||
if (cmsPipelineStageCount(*Lut) == 0)
|
||||
nGridPoints = 2;
|
||||
else
|
||||
{
|
||||
nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags);
|
||||
|
||||
// Lab16 as input cannot be optimized by a CLUT due to centering issues, thanks to Mike Chaney for discovering this.
|
||||
if (!(*dwFlags & cmsFLAGS_FORCE_CLUT) && (ColorSpace == cmsSigLabData) && (T_BYTES(*InputFormat) == 2)) return FALSE;
|
||||
}
|
||||
|
||||
Src = *Lut;
|
||||
|
||||
@ -813,6 +818,11 @@ Error:
|
||||
Dest ->OutputChannels,
|
||||
DataSetOut);
|
||||
|
||||
if (p16 == NULL) {
|
||||
cmsPipelineFree(Dest);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmsPipelineSetOptimizationParameters(Dest, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -522,7 +522,7 @@ cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...)
|
||||
va_start(args, frm);
|
||||
|
||||
len = vsnprintf((char*) Buffer, 2047, frm, args);
|
||||
if (len < 0) {
|
||||
if (len < 0 || len >= 2047) {
|
||||
va_end(args);
|
||||
return FALSE; // Truncated, which is a fatal error for us
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -152,9 +152,12 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
|
||||
// Convert black to Lab
|
||||
cmsDoTransform(xform, Black, &Lab, 1);
|
||||
|
||||
// Force it to be neutral, check for inconsistencies
|
||||
Lab.a = Lab.b = 0;
|
||||
if (Lab.L > 50 || Lab.L < 0) Lab.L = 0;
|
||||
if (Lab.L > 95)
|
||||
Lab.L = 0; // for synthetical negative profiles
|
||||
else if (Lab.L < 0)
|
||||
Lab.L = 0;
|
||||
else if (Lab.L > 50)
|
||||
Lab.L = 50;
|
||||
|
||||
// Free the resources
|
||||
cmsDeleteTransform(xform);
|
||||
@ -352,7 +355,7 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[]
|
||||
if (fabs(a) < 1.0E-10) {
|
||||
|
||||
if (fabs(b) < 1.0E-10) return 0;
|
||||
return cmsmin(0, cmsmax(50, -c/b ));
|
||||
return cmsmax(0, cmsmin(50, -c/b ));
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -4786,7 +4786,6 @@ cmsBool ReadMPEElem(struct _cms_typehandler_struct* self,
|
||||
|
||||
return TRUE;
|
||||
|
||||
cmsUNUSED_PARAMETER(SizeOfTag);
|
||||
cmsUNUSED_PARAMETER(n);
|
||||
}
|
||||
|
||||
@ -4894,9 +4893,11 @@ cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, v
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Before = io ->Tell(io);
|
||||
|
||||
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;
|
||||
|
||||
@ -5645,9 +5646,7 @@ void* Type_VideoSignal_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER*
|
||||
{
|
||||
cmsVideoSignalType* cicp = NULL;
|
||||
|
||||
if (SizeOfTag != 8) return NULL;
|
||||
|
||||
if (!_cmsReadUInt32Number(io, NULL)) return NULL;
|
||||
if (SizeOfTag != 4) return NULL;
|
||||
|
||||
cicp = (cmsVideoSignalType*)_cmsCalloc(self->ContextID, 1, sizeof(cmsVideoSignalType));
|
||||
if (cicp == NULL) return NULL;
|
||||
@ -5671,7 +5670,6 @@ cmsBool Type_VideoSignal_Write(struct _cms_typehandler_struct* self, cmsIOHANDLE
|
||||
{
|
||||
cmsVideoSignalType* cicp = (cmsVideoSignalType*)Ptr;
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
|
||||
if (!_cmsWriteUInt8Number(io, cicp->ColourPrimaries)) return FALSE;
|
||||
if (!_cmsWriteUInt8Number(io, cicp->TransferCharacteristics)) return FALSE;
|
||||
if (!_cmsWriteUInt8Number(io, cicp->MatrixCoefficients)) return FALSE;
|
||||
@ -5744,11 +5742,11 @@ void Type_MHC2_Free(struct _cms_typehandler_struct* self, void* Ptr)
|
||||
|
||||
void* Type_MHC2_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
|
||||
{
|
||||
cmsMHC2Type* mhc2 = _cmsDupMem(self->ContextID, Ptr, sizeof(cmsMHC2Type));
|
||||
cmsMHC2Type* mhc2 = (cmsMHC2Type*)_cmsDupMem(self->ContextID, Ptr, sizeof(cmsMHC2Type));
|
||||
|
||||
mhc2->RedCurve = _cmsDupMem(self->ContextID, mhc2->RedCurve, mhc2->CurveEntries*sizeof(cmsFloat64Number));
|
||||
mhc2->GreenCurve = _cmsDupMem(self->ContextID, mhc2->GreenCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
|
||||
mhc2->BlueCurve = _cmsDupMem(self->ContextID, mhc2->BlueCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
|
||||
mhc2->RedCurve = (cmsFloat64Number*) _cmsDupMem(self->ContextID, mhc2->RedCurve, mhc2->CurveEntries*sizeof(cmsFloat64Number));
|
||||
mhc2->GreenCurve = (cmsFloat64Number*) _cmsDupMem(self->ContextID, mhc2->GreenCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
|
||||
mhc2->BlueCurve = (cmsFloat64Number*) _cmsDupMem(self->ContextID, mhc2->BlueCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
|
||||
|
||||
if (mhc2->RedCurve == NULL ||
|
||||
mhc2->GreenCurve == NULL ||
|
||||
@ -5786,7 +5784,6 @@ cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
|
||||
cmsUInt32Number MatrixOffset;
|
||||
cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
|
||||
if (!_cmsWriteUInt32Number(io, mhc2->CurveEntries)) return FALSE;
|
||||
|
||||
if (!_cmsWrite15Fixed16Number(io, mhc2->MinLuminance)) return FALSE;
|
||||
@ -5811,10 +5808,20 @@ cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
|
||||
}
|
||||
|
||||
OffsetRedTable = io->Tell(io) - BaseOffset;
|
||||
|
||||
if(!_cmsWriteUInt32Number(io, cmsSigS15Fixed16ArrayType)) return FALSE;
|
||||
if(!_cmsWriteUInt32Number(io, 0)) return FALSE;
|
||||
|
||||
if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->RedCurve)) return FALSE;
|
||||
|
||||
OffsetGreenTable = io->Tell(io) - BaseOffset;
|
||||
if (!_cmsWriteUInt32Number(io, cmsSigS15Fixed16ArrayType)) return FALSE;
|
||||
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
|
||||
if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->GreenCurve)) return FALSE;
|
||||
|
||||
OffsetBlueTable = io->Tell(io) - BaseOffset;
|
||||
if (!_cmsWriteUInt32Number(io, cmsSigS15Fixed16ArrayType)) return FALSE;
|
||||
if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
|
||||
if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->BlueCurve)) return FALSE;
|
||||
|
||||
if (!io->Seek(io, TablesOffsetPos)) return FALSE;
|
||||
@ -5858,8 +5865,6 @@ void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
|
||||
cmsUInt32Number MatrixOffset;
|
||||
cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
|
||||
|
||||
if (!_cmsReadUInt32Number(io, NULL)) return NULL;
|
||||
|
||||
mhc2 = (cmsMHC2Type*)_cmsCalloc(self->ContextID, 1, sizeof(cmsMHC2Type));
|
||||
if (mhc2 == NULL) return NULL;
|
||||
|
||||
@ -5890,9 +5895,10 @@ void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
|
||||
if (!ReadDoublesAt(io, BaseOffset + MatrixOffset, 3*4, &mhc2->XYZ2XYZmatrix[0][0])) goto Error;
|
||||
}
|
||||
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetRedTable, mhc2->CurveEntries, mhc2->RedCurve)) goto Error;
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetGreenTable, mhc2->CurveEntries, mhc2->GreenCurve)) goto Error;
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetBlueTable, mhc2->CurveEntries, mhc2->BlueCurve)) goto Error;
|
||||
// Skip sf32 tag and filler (8bytes)
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetRedTable + 8, mhc2->CurveEntries, mhc2->RedCurve)) goto Error;
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetGreenTable + 8, mhc2->CurveEntries, mhc2->GreenCurve)) goto Error;
|
||||
if (!ReadDoublesAt(io, BaseOffset + OffsetBlueTable + 8, mhc2->CurveEntries, mhc2->BlueCurve)) goto Error;
|
||||
|
||||
// Success
|
||||
*nItems = 1;
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -400,7 +400,7 @@ int InkLimitingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUI
|
||||
SumCMY = (cmsFloat64Number) In[0] + In[1] + In[2];
|
||||
SumCMYK = SumCMY + In[3];
|
||||
|
||||
if (SumCMYK > InkLimit) {
|
||||
if (SumCMYK > InkLimit && SumCMY > 0) {
|
||||
|
||||
Ratio = 1 - ((SumCMYK - InkLimit) / SumCMY);
|
||||
if (Ratio < 0)
|
||||
@ -513,16 +513,20 @@ cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIE
|
||||
cmsSetColorSpace(hProfile, cmsSigLabData);
|
||||
cmsSetPCS(hProfile, cmsSigLabData);
|
||||
|
||||
if (!SetTextTags(hProfile, L"Lab identity built-in")) return NULL;
|
||||
if (!SetTextTags(hProfile, L"Lab identity built-in"))
|
||||
goto Error;
|
||||
|
||||
// An identity LUT is all we need
|
||||
LUT = cmsPipelineAlloc(ContextID, 3, 3);
|
||||
if (LUT == NULL) goto Error;
|
||||
if (LUT == NULL)
|
||||
goto Error;
|
||||
|
||||
if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCLut(ContextID, 3)))
|
||||
goto Error;
|
||||
|
||||
if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error;
|
||||
if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT))
|
||||
goto Error;
|
||||
|
||||
cmsPipelineFree(LUT);
|
||||
|
||||
return hProfile;
|
||||
@ -550,8 +554,14 @@ cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIE
|
||||
{
|
||||
cmsHPROFILE hProfile;
|
||||
cmsPipeline* LUT = NULL;
|
||||
cmsCIEXYZ xyz;
|
||||
|
||||
hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);
|
||||
if (WhitePoint == NULL)
|
||||
xyz = *cmsD50_XYZ();
|
||||
else
|
||||
cmsxyY2XYZ(&xyz, WhitePoint);
|
||||
|
||||
hProfile = cmsCreateRGBProfileTHR(ContextID, NULL, NULL, NULL);
|
||||
if (hProfile == NULL) return NULL;
|
||||
|
||||
cmsSetProfileVersion(hProfile, 4.4);
|
||||
@ -560,6 +570,7 @@ cmsHPROFILE CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIE
|
||||
cmsSetColorSpace(hProfile, cmsSigLabData);
|
||||
cmsSetPCS(hProfile, cmsSigLabData);
|
||||
|
||||
if (!cmsWriteTag(hProfile, cmsSigMediaWhitePointTag, &xyz)) goto Error;
|
||||
if (!SetTextTags(hProfile, L"Lab identity built-in")) goto Error;
|
||||
|
||||
// An empty LUTs is all we need
|
||||
@ -929,25 +940,24 @@ cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
|
||||
|
||||
for (i=0; i < MAX_INPUT_DIMENSIONS; i++) Dimensions[i] = nLUTPoints;
|
||||
CLUT = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, 3, 3, NULL);
|
||||
if (CLUT == NULL) goto Error;
|
||||
|
||||
|
||||
if (!cmsStageSampleCLut16bit(CLUT, bchswSampler, (void*) &bchsw, 0)) {
|
||||
|
||||
// Shouldn't reach here
|
||||
if (CLUT == NULL)
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT)) {
|
||||
if (!cmsStageSampleCLut16bit(CLUT, bchswSampler, (void*) &bchsw, 0))
|
||||
goto Error;
|
||||
|
||||
if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT))
|
||||
goto Error;
|
||||
}
|
||||
|
||||
// Create tags
|
||||
if (!SetTextTags(hICC, L"BCHS built-in")) return NULL;
|
||||
if (!SetTextTags(hICC, L"BCHS built-in"))
|
||||
goto Error;
|
||||
|
||||
cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*) cmsD50_XYZ());
|
||||
if (!cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*)cmsD50_XYZ()))
|
||||
goto Error;
|
||||
|
||||
cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) Pipeline);
|
||||
if (!cmsWriteTag(hICC, cmsSigAToB0Tag, (void*)Pipeline))
|
||||
goto Error;
|
||||
|
||||
// Pipeline is already on virtual profile
|
||||
cmsPipelineFree(Pipeline);
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -1101,6 +1101,8 @@ cmsBool IsProperColorSpace(cmsColorSpaceSignature Check, cmsUInt32Number dwForm
|
||||
int Space1 = (int) T_COLORSPACE(dwFormat);
|
||||
int Space2 = _cmsLCMScolorSpace(Check);
|
||||
|
||||
if (dwFormat == 0) return TRUE; // Bypass used by linkicc
|
||||
|
||||
if (Space1 == PT_ANY) return (T_CHANNELS(dwFormat) == cmsChannelsOf(Check));
|
||||
if (Space1 == Space2) return TRUE;
|
||||
|
||||
@ -1183,6 +1185,11 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
|
||||
if (hGamutProfile == NULL) dwFlags &= ~cmsFLAGS_GAMUTCHECK;
|
||||
}
|
||||
|
||||
if ((dwFlags & cmsFLAGS_GAMUTCHECK) && (nGamutPCSposition <= 0 || nGamutPCSposition >= nProfiles - 1)) {
|
||||
cmsSignalError(ContextID, cmsERROR_RANGE, "Wrong gamut PCS position '%d'", nGamutPCSposition);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// On floating point transforms, inhibit cache
|
||||
if (_cmsFormatterIsFloat(InputFormat) || _cmsFormatterIsFloat(OutputFormat))
|
||||
dwFlags |= cmsFLAGS_NOCACHE;
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2025 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
@ -52,7 +52,7 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Version 2.17
|
||||
// Version 2.18
|
||||
//
|
||||
|
||||
#ifndef _lcms2_H
|
||||
@ -116,7 +116,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Version/release
|
||||
#define LCMS_VERSION 2170
|
||||
#define LCMS_VERSION 2180
|
||||
|
||||
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
|
||||
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2024 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2026 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"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user