#include "kcms_utils.h" #define SAMPLE_WORDS "A profile created using kcms_create" KcsProfileId profileid; KcsStatusId status; KcsAttributeValue attrValue; KcsAttributeValue *attrValue2; KcsAttributeValue *attrValuePtr; KcsErrDesc errDesc; int sizemeas, size, nvalues, i, j; time_t clocktime; struct tm *datetime; size_t rc; char *description; char attr[256]; double test_double[3]; /* Fill out the measurement structures - The illuminant must be D50 */ test_double[0] = 0.9642; test_double[1] = 1.0; test_double[2] = 0.8249; /* open or create a profile, then set some attributes */ if ((description = (char *)malloc(strlen(SAMPLE_WORDS) + 1)) == NULL) { perror("malloc failed : "); KcsFreeProfile(profileid); exit(1); } memset(description, 0, strlen(SAMPLE_WORDS) + 1); strcpy(description, SAMPLE_WORDS); /* the function used below can be found in kcms_utils.c in appendix */ if ((attrValue2 = string2icTextAttrValue(description)) == NULL) { fprintf(stderr, "conversion to AttrValue failed \n"); KcsFreeProfile(profileid); exit(1); } if (KcsSetAttribute(profileid, icSigProfileDescriptionTag, attrValue2) != KCS_SUCCESS) { KcsGetLastError(&errDesc); printf("Set Attribute error: %s\n", errDesc.desc); exit(1); } free(attrValue2); free(description); size = sizeof(KcsAttributeBase) + sizeof(icHeader); attrValuePtr = (KcsAttributeValue *)malloc(size); /* Build the header */ attrValuePtr->base.type = icSigHeaderType; attrValuePtr->base.sizeOfType = sizeof(icHeader); attrValuePtr->base.countSupplied = 1; KcsGetAttribute(profileid, icSigHeaderTag, attrValuePtr); attrValuePtr->val.icHeader.size = 0; /* The following three values do not have to be set if you do a * GetAttribute on the header, since the Create should set them for you. * If you do not do a GetAttribute of the header, you must set these: * attrValuePtr->val.icHeader.cmmId = 0x4b434d53; * attrValuePtr->val.icHeader.version =icVersionNumber; * attrValuePtr->val.icHeader.magic = icMagicNumber; */ attrValuePtr->val.icHeader.deviceClass = icSigDisplayClass; attrValuePtr->val.icHeader.colorSpace = icSigRgbData; attrValuePtr->val.icHeader.pcs = icSigXYZData; /* Get the time from the system */ clocktime = time(NULL); datetime = localtime(&clocktime); attrValuePtr->val.icHeader.date.seconds = (icUInt16Number)datetime->tm_sec; attrValuePtr->val.icHeader.date.minutes = (icUInt16Number)datetime->tm_min; attrValuePtr->val.icHeader.date.hours = (icUInt16Number)datetime->tm_hour; attrValuePtr->val.icHeader.date.day = (icUInt16Number)datetime->tm_mday; attrValuePtr->val.icHeader.date.month = (icUInt16Number)datetime->tm_mon + 1; attrValuePtr->val.icHeader.date.year = (icUInt16Number)datetime->tm_year; attrValuePtr->val.icHeader.platform = icSigSolaris; attrValuePtr->val.icHeader.flags = icEmbeddedProfileFalse || icUseAnywhere; strcpy(description,"SUNW "); memcpy(&attrValuePtr->val.icHeader.manufacturer, description, 4); attrValuePtr->val.icHeader.model = 0; attrValuePtr->val.icHeader.attributes[0] = 0; attrValuePtr->val.icHeader.attributes[1] = 0; attrValuePtr->val.icHeader.renderingIntent = icPerceptual; attrValuePtr->val.icHeader.illuminant.X = double2icfixed(test_double[0], icSigS15Fixed16ArrayType); attrValuePtr->val.icHeader.illuminant.Y = double2icfixed(test_double[1], icSigS15Fixed16ArrayType); attrValuePtr->val.icHeader.illuminant.Z = double2icfixed(test_double[2], icSigS15Fixed16ArrayType); rc = KcsSetAttribute(profileid, icSigHeaderTag, attrValuePtr); if(rc != KCS_SUCCESS) { rc =KcsGetLastError(&errDesc); fprintf(stderr, "unable to set header: %s\n", errDesc.desc); KcsFreeProfile(profileid); return(-1) |