Skip to content

Commit

Permalink
Added compatibilty w/ previous releases on alarm codes
Browse files Browse the repository at this point in the history
Floating point transforms now also handle alarm codes
  • Loading branch information
mm2 committed Nov 7, 2024
1 parent 607fe1a commit 70a39bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cmsxform.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@ void FloatXFORM(_cmsTRANSFORM* p,
// Is current color out of gamut?
if (OutOfGamut > 0.0) {

_cmsAlarmCodesChunkType* ContextAlarmCodes = (_cmsAlarmCodesChunkType*)_cmsContextGetClientChunk(p->ContextID, AlarmCodesContext);

// Certainly, out of gamut
for (c = 0; c < cmsMAXCHANNELS; c++)
fOut[c] = 1.0;
fOut[c] = ContextAlarmCodes->AlarmCodes[c] / 65535.0;

}
else {
Expand Down
11 changes: 9 additions & 2 deletions testbed/testcms2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8828,6 +8828,10 @@ int CheckSaveLinearizationDevicelink(void)
static
int CheckGamutCheckFloats(void)
{

cmsUInt16Number alarms[16] = { 0x0f0f,3,4,5,6,7,8,9,10 };


cmsHPROFILE hLab = cmsCreateLab4Profile(NULL);
cmsHPROFILE hNull = cmsCreateNULLProfile();
cmsHPROFILE hsRGB = cmsCreate_sRGBProfile();
Expand All @@ -8845,9 +8849,12 @@ int CheckGamutCheckFloats(void)
cmsCIELab Lab2 = { 50, -10, 12 };

cmsUInt8Number gamut;

cmsSetAlarmCodes(alarms);

cmsDoTransform(xfrm, &Lab, &gamut, 1); // Gives the alarm != 0
if (gamut == 0)
Fail("Gamut check not zero");
if (gamut != 0x0f)
Fail("Gamut check not good");

cmsDoTransform(xfrm, &Lab2, &gamut, 1);
if (gamut != 0)
Expand Down

0 comments on commit 70a39bf

Please sign in to comment.