Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mm2/Little-CMS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmstypes.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/cmstypes.c b/src/cmstypes.c
index e056731..4b7e7ab 100644
--- a/src/cmstypes.c
+++ b/src/cmstypes.c
@@ -1935,17 +1935,25 @@ cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
// That should be all
if (mpe != NULL) {
- cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8");
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8");
return FALSE;
}
if (clut == NULL)
clutPoints = 0;
- else
- clutPoints = clut->Params->nSamples[0];
-
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->InputChannels)) return FALSE;
- if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->OutputChannels)) return FALSE;
+ else {
+ // Lut8 only allows same CLUT points in all dimensions
+ clutPoints = clut->Params->nSamples[0];
+ for (i = 1; i < cmsPipelineInputChannels(NewLUT); i++) {
+ if (clut->Params->nSamples[i] != clutPoints) {
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16");
+ return FALSE;
+ }
+ }
+ }
+
+ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineInputChannels(NewLUT))) return FALSE;
+ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number)cmsPipelineOutputChannels(NewLUT))) return FALSE;
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
@@ -2218,7 +2226,7 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
// That should be all
if (mpe != NULL) {
- cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16");
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16");
return FALSE;
}
@@ -2227,8 +2235,16 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
if (clut == NULL)
clutPoints = 0;
- else
- clutPoints = clut->Params->nSamples[0];
+ else {
+ // Lut16 only allows same CLUT points in all dimensions
+ clutPoints = clut->Params->nSamples[0];
+ for (i = 1; i < InputChannels; i++) {
+ if (clut->Params->nSamples[i] != clutPoints) {
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT with different samples per dimension not suitable to be saved as LUT16");
+ return FALSE;
+ }
+ }
+ }
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE;
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE;