KCMS Application Developer's Guide

KcsAttributeValue

typedef struct KcsAttributeValue_s {
      KcsAttributeBase                               base;
      union KcsAttributeValueValue_s {
           struct tm                 dateTimeVal;
           long                      longVal[KcsExtendableArray];
           double                    doubleVal[KcsExtendableArray];
           char                      byteVal[KcsExtendableArray];
           unsigned char             uByteVal[KcsExtendableArray];
           short                     shortVal[KcsExtendableArray];
           unsigned short            uShortVal[KcsExtendableArray];
           unsigned long             uLongVal[KcsExtendableArray];
           KcsPixelLayoutSpeeds      layoutVal[KcsExtendablePixelLayout];
           /* ICC 3.0 values */
           icText                    icText;
           icData                    icData;
           icCurve                   icCurve;
           icUcrBg                   icUcrBg;
           icNamedColor2             icNamedColor2;
           icScreening               icScreening;
           icSignature               icSignature;
           icMeasurement             icMeasurement;
           icDateTimeNumber          icDateTime;
           icViewingCondition        icViewingCondition;
           icTextDescription         icTextDescription;
           icProfileSequenceDesc     icProfileSequenceDescription;
           icXYZArray                icXYZ;
           icInt8Array               icInt8Array;
           icInt16Array              icInt16Array;
           icInt32Array              icInt32Array;
           icInt64Array              icInt64Array;
           icUInt8Array              icUInt8Array;
           icUInt16Array             icUInt16Array;
           icUInt32Array             icUInt32Array;
           icUInt64Array             icUInt64Array;
           icS15Fixed16Array         icS15Fixed16Array;
           icU16Fixed16Array         icU16Fixed16Array
           icHeader                  icHeader
      } KcsAttributeValueValue;
 } KcsAttributeValue;

Note -

The KcsAttributeValueValue data type is included in this type definition.


The KcsAttributeValue structure is the data type of one argument in:

A variable of data type KcsAttributeValue holds the value of an attribute. An attribute's value fits in a normal KcsAttributeValue structure. However, your application may have to extend the KcsAttributeValue structure if the number of values an attribute contains is greater than the number in the default size of the structure. The "C" API macro KCS_DEFAULT_ATTRIB_COUNT returns the values that a variable of this type can hold. (For more information on KCS_DEFAULT_ATTRIB_COUNT, see the description of KcsAttributeBase on "KcsAttributeBase".) For example, to have more values in an attribute than the value returned from the macro, your application can extend the structure by allocating more memory and then casting it as a pointer to a KcsAttributeValue structure. Because it is specified as an array at the end of the structure, and C does not check array bounds, your application can allocate a piece of memory larger than KcsAttributeValue and treat the extra memory as an extension of the val arrays. This allows your application to access the values using the array operator (myAttributeValuePtr->val.doubleVal[i]).

For example, the following code shows you how to get the colorant from a profile.


Example 3-1 KcsAttributeValue

/* Get the colorants */
 /* Red */
 KcsAttributeValue     *attrValuePtr;

 attrValuePtr = (KcsAttributeValue *)malloc(sizeof(KcsAttributeBase) +
                sizeof(icXYZNumber) );
 attrValuePtr->base.type = icSigXYZArrayType;
 attrValuePtr->base.countSupplied = 1;
 status = KcsGetAttribute(profileid, icSigRedColorantTag, attrValuePtr);
 if(status != KCS_SUCCESS) {
      status = KcsGetLastError(&errDesc);
      printf("GetAttribute error: %s\n", errDesc.desc);
      KcsFreeProfile(profileid);
      exit(1);
 }

 XYZval = (icXYZNumber *)attrValuePtr->val.icXYZ.data;
 printf("Red X=%f Y=%f Z=%f\n", icfixed2double(XYZval->X, icSigS15Fixed16ArrayType),
             icfixed2double(XYZval->Y, icSigS15Fixed16ArrayType), icfixed2double(XYZval->Z,
             icSigS15Fixed16ArrayType));
 /* Green */   
 status = KcsGetAttribute(profileid, icSigGreenColorantTag, attrValuePtr);
 if(status != KCS_SUCCESS) {
      status = KcsGetLastError(&errDesc);
      printf("SetAttribute error: %s\n", errDesc.desc);
      KcsFreeProfile(profileid);
      exit(1);
 }

 XYZval = (icXYZNumber *)attrValuePtr->val.icXYZ.data;
 printf("Green X=%f Y=%f Z=%f\n", icfixed2double(XYZval->X, icSigS15Fixed16ArrayType),
             icfixed2double(XYZval->Y, icSigS15Fixed16ArrayType), icfixed2double(XYZval->Z,
             icSigS15Fixed16ArrayType));

 /* Blue */
 status = KcsGetAttribute(profileid, icSigBlueColorantTag, attrValuePtr);
 if(status != KCS_SUCCESS) {
      status = KcsGetLastError(&errDesc);
      printf("SetAttribute error: %s\n", errDesc.desc);
      KcsFreeProfile(profileid);
      exit(1);
 }

 XYZval = (icXYZNumber *)attrValuePtr->val.icXYZ.data;
 printf("Blue X=%f Y=%f Z=%f\n", icfixed2double(XYZval->X, icSigS15Fixed16ArrayType),
             icfixed2double(XYZval->Y, icSigS15Fixed16ArrayType), icfixed2double(XYZval->Z,
             icSigS15Fixed16ArrayType));
 free(attrValuePtr);

If an attribute returns just one long value, use the following code fragment:


KcsAttributeValue myAttributeValue;
 myAttributeValue.base.countSupplied = 1;
 KcsGetAttribute(myProfile, myAttributeName, &myAttributeValue);