KCMS Application Developer's Guide

Example


Example 4-12 KcsSetCallback()

/* template function declaration */

 int myProgressCallback(KcsProfileId profileid, unsigned long
             current, unsigned long total, KcsFunction
             operation, void *userDefinedData);

 KcsProfileId                        completeProfile;
 KcsPixelLayout     pixelLayoutIn;

 /* the profiles have been loaded and connected, now set up the
 * callback to be active for both the optimize and evaluate
 * functions */

 status = KcsSetCallback(KcsOptFunc + KcsEvalFunc,
             (KcsCallbackFunction)myProgressCallback, NULL );
 if (status != KCS_SUCCESS) {
     fprintf(stderr, "Callback function call failed\n");
 }
 
 printf("Optimizing the complete profile \n");
 status = KcsOptimizeProfile(completeProfile, KcsOptSpeed, KcsLoadAllNow);
 /* check status here*/
 /* set up the pixel layout */
 status = KcsEvaluate(completeProfile, op, &pixelLayoutIn, &pixelLayoutIn);
 /* check status here*/

 /* This is my callback function */

 int myProgressCallback(KcsProfileId profileid, unsigned long current,
         unsigned long total, KcsFunction operation, void *userDefinedData)

 {
     int            pcent;
 
     pcent = (int) (((float)current/ (float)total) *100.0);
     fprintf(stderr,"Optimize+Evaluate is %3d percent complete\n", pcent);
     fflush(stderr);
     return(KCS_SUCCESS);
 /* Free callback resources*/
 KcsSetCallback (KcsOptFunc+KcsEvalFunc, NULL, NULL);
 }