summaryrefslogtreecommitdiff
path: root/src/cmsnamed.c
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-04-12 15:48:03 +0200
committerMarti Maria <info@littlecms.com>2011-04-12 15:48:03 +0200
commit97f22bda885166a18e346db8dd24bd66bc4615cd (patch)
treedf399bb7e3db23ae02b8a0b01262fe5041f6c783 /src/cmsnamed.c
parentb735a01cd82f08ef46733c9f19eb08ba1a6623af (diff)
downloadlcms2-97f22bda885166a18e346db8dd24bd66bc4615cd.tar.gz
Added named color functionality
Diffstat (limited to 'src/cmsnamed.c')
-rw-r--r--src/cmsnamed.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/cmsnamed.c b/src/cmsnamed.c
index d1a86b6..f4f423d 100644
--- a/src/cmsnamed.c
+++ b/src/cmsnamed.c
@@ -619,6 +619,24 @@ void* DupNamedColorList(cmsStage* mpe)
}
static
+void EvalNamedColorPCS(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
+{
+ cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data;
+ cmsUInt16Number index = (cmsUInt16Number) _cmsQuickSaturateWord(In[0] * 65535.0);
+
+ if (index >= NamedColorList-> nColors) {
+ cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range; ignored", index);
+ }
+ else {
+
+ // Named color always uses Lab
+ Out[0] = (cmsFloat32Number) (NamedColorList->List[index].PCS[0] / 65535.0);
+ Out[1] = (cmsFloat32Number) (NamedColorList->List[index].PCS[1] / 65535.0);
+ Out[2] = (cmsFloat32Number) (NamedColorList->List[index].PCS[2] / 65535.0);
+ }
+}
+
+static
void EvalNamedColor(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
{
cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data;
@@ -636,12 +654,12 @@ void EvalNamedColor(const cmsFloat32Number In[], cmsFloat32Number Out[], const c
// Named color lookup element
-cmsStage* _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList)
+cmsStage* _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsBool UsePCS)
{
return _cmsStageAllocPlaceholder(NamedColorList ->ContextID,
cmsSigNamedColorElemType,
- 1, 3,
- EvalNamedColor,
+ 1, UsePCS ? 3 : NamedColorList ->ColorantCount,
+ UsePCS ? EvalNamedColorPCS : EvalNamedColor,
DupNamedColorList,
FreeNamedColorList,
cmsDupNamedColorList(NamedColorList));