To call KcsUpdateProfile() successfully, the profile must contain a small number of attributes that identify the type of device the profile represents. It is assumed that the profile already contains these attributes.
An example is given of how to allocate and fill out the arguments required to call KcsUpdateProfile().
#pragma ident "@(#) kcms_update.c" /* kcs_update.c */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <math.h> #include <kcms/kcs.h> #include <kcms/kcstypes.h> #include <kcms/kcsattrb.h> float Luminance_float_out[3][256]; /* test code to check profile calibration * / main(int argc, char **argv) { KcsCalibrationData *calData; KcsProfileDesc x_desc, desc; KcsProfileId profileid; KcsStatusId status; KcsAttributeValue attrValue; KcsErrDesc errDesc; int levels = 256, channels = 3; int sizemeas, nvalues, i, j; FILE *simfile; float input_val; size_t rc; /* Read in the measured calibration data from a file */ /* file lum_out should be located in demo directory with this program */ if ((simfile = fopen("lum_out", "r")) == NULL) { fprintf(stderr,"cannot open output luminance file\n"); exit(1); } for (i=0; i<channels; i++) for (j=0; j<levels; j++) Luminance_float_out[i][j] = 0.0; nvalues = levels * channels; rc = fread(Luminance_float_out, sizeof(float), nvalues, simfile); fclose(simfile); /* Fill out the measurement structures */ sizemeas = (int) (sizeof(KcsMeasurementBase) + sizeof(long) + levels); calData = (KcsCalibrationData *) malloc(sizemeas); calData->base.countSupplied = levels; calData->base.numInComp = 3; calData->base.numOutComp = 3; calData->base.inputSpace = KcsRGB; calData->base.outputSpace = KcsRGB; for (i=0; i< levels; i++) { calData->val.patch[i].weight = 1.0; calData->val.patch[i].standardDeviation = 0.0; calData->val.patch[i].sampleType = KcsChromatic; calData->val.patch[i].input[KcsRGB_R] = (float)i/255; calData->val.patch[i].input[KcsRGB_G] = (float)i/255; calData->val.patch[i].input[KcsRGB_B] = (float)i/255; calData->val.patch[i].input[3] = 0.0; calData->val.patch[i].output[KcsRGB_R] = Luminance_float_out[0][i]; calData->val.patch[i].output[KcsRGB_G] = Luminance_float_out[1][i]; calData->val.patch[i].output[KcsRGB_B] = Luminance_float_out[2][i]; calData->val.patch[i].output[3] = 0.0; } calData->val.patch[0].sampleType = KcsBlack; calData->val.patch[255].sampleType = KcsWhite; if (!argv[1]) { fprintf(stderr, "Usage kcms_update profile_in [profile_out]\n"); exit(1); } /* Let the library open the file */ x_desc.type = KcsSolarisProfile; x_desc.desc.solarisFile.fileName = argv[optind]; x_desc.desc.solarisFile.hostName = NULL; x_desc.desc.solarisFile.oflag = O_RDWR; x_desc.desc.solarisFile.mode = 0; status = KcsLoadProfile(&profileid, &x_desc, KcsLoadAllNow); if(status != KCS_SUCCESS) { status = KcsGetLastError(&errDesc); printf("LoadProfile error: %s\n", errDesc.desc); } status = KcsUpdateProfile(profileid, NULL, calData, NULL); if(status != KCS_SUCCESS) { status = KcsGetLastError(&errDesc); printf("UpdateProfile error: %s\n", errDesc.desc); KcsFreeProfile(profileid); exit(1); } if (argv[2]) { /* Save to an output file */ desc.type = KcsSolarisProfile; desc.desc.solarisFile.fileName = argv[2]; desc.desc.solarisFile.hostName = NULL; desc.desc.solarisFile.oflag = O_RDWR|O_CREAT|O_TRUNC; |