Exemple #1
0
int main(int argc, char *argv[])
{
    WORD Input[MAXCHANNELS], Output[MAXCHANNELS], PCSLab[MAXCHANNELS], PCSxyz[MAXCHANNELS];

    
    fprintf(stderr, "little cms ColorSpace conversion calculator - v1.8\n\n");

      if (argc == 1)  
              Help();              

      HandleSwitches(argc, argv);

      cmsSetErrorHandler(MyErrorHandler);

      OpenTransforms();
      
      for(;;) {

          if (xisatty(stdin))
              printf("\nEnter values, 'q' to quit\n");

          if (feof(stdin))
              break;

          TakeValues(Input);
          cmsDoTransform(hTrans, Input, Output, 1);

          if (Verbose) {

            if (hTransXYZ) cmsDoTransform(hTransXYZ, Input, PCSxyz, 1);
            if (hTransLab) cmsDoTransform(hTransLab, Input, PCSLab, 1);
          }
                    
          if (xisatty(stdin))
                printf("\n");
         
          PrintResults(Output, OutputColorSpace); printf("\n");

          if (Verbose && hTransXYZ && hTransLab) {

            PrintResults(PCSxyz, icSigXYZData); printf("\n");
            PrintResults(PCSLab, icSigLabData); printf("\n");
          }

      }

          
      return 0;     
}
Exemple #2
0
// The main sink
int main(int argc, char *argv[])
{    
    cmsUInt16Number Output[cmsMAXCHANNELS];
    cmsFloat64Number OutputFloat[cmsMAXCHANNELS];
    cmsFloat64Number InputFloat[cmsMAXCHANNELS];

    int nPatch = 0;

    fprintf(stderr, "LittleCMS ColorSpace conversion calculator - 4.3 [LittleCMS %2.2f]\n", LCMS_VERSION / 1000.0);

    InitUtils("transicc");

    Verbose = 1;

    if (argc == 1) {

        Help();              
        return 0;
    }

    HandleSwitches(argc, argv);

    // Open profiles, create transforms
    if (!OpenTransforms()) return 1;

    // Open CGATS input if specified
    OpenCGATSFiles(argc, argv);

    // Main loop: read all values and convert them
    for(;;) {

        if (hIT8in != NULL) {

            if (nPatch >= nMaxPatches) break;
            TakeCGATSValues(nPatch++, InputFloat);

        } else {

            if (feof(stdin)) break;         
            TakeFloatValues(InputFloat);

        }

        if (lIsFloat) 
            cmsDoTransform(hTrans, InputFloat, OutputFloat, 1);
        else
            cmsDoTransform(hTrans, InputFloat, Output, 1);


        if (hIT8out != NULL) {

            PutCGATSValues(OutputFloat);
        }
        else {

            if (lIsFloat) {
                PrintFloatResults(OutputFloat); PrintPCSFloat(InputFloat);
            }
            else {
                PrintEncodedResults(Output);   PrintPCSEncoded(InputFloat);      
            }

        }
    }


    // Cleanup
    CloseTransforms();

    if (hIT8in)
        cmsIT8Free(hIT8in);

    if (hIT8out) {      
        cmsIT8SaveToFile(hIT8out, CGATSoutFilename);
        cmsIT8Free(hIT8out);
    }

    // All is ok
    return 0;     
}
void mexFunction(
                 int nlhs,              // Number of left hand side (output) arguments
                 mxArray *plhs[],       // Array of left hand side arguments
                 int nrhs,              // Number of right hand side (input) arguments
                 const mxArray *prhs[]  // Array of right hand side arguments
                 )
{
    
    char CommandLine[4096+1];
    char *pt, *argv[128];
    int argc = 1;
    
    
    if (nrhs != 2) {    

        PrintHelp();              
        return;
    }
    
    
    if(nlhs > 1) {        
        FatalError("Too many output arguments.");
    }
    
    
    // Setup error handler
    
    cmsSetErrorHandler(MatLabErrorHandler);
    
    // Defaults

    Verbose     = 0;
    cInProf     = NULL;
    cOutProf    = NULL;
    cProofing   = NULL;

	lMultiProfileChain = FALSE;
	nProfiles   = 0;

    Intent      = INTENT_PERCEPTUAL;
    ProofingIntent          = INTENT_ABSOLUTE_COLORIMETRIC;
    PrecalcMode = 0;
    BlackPointCompensation  = FALSE;
    lIsDeviceLink           = FALSE;

    // Check types. Fist parameter is array of values, second parameter is command line
    
    if (!mxIsNumeric(prhs[0]))
            FatalError("Type mismatch on argument 1 -- Must be numeric");

    if (!mxIsChar(prhs[1]))
            FatalError("Type mismatch on argument 2 -- Must be string");




    // Unpack string to command line buffer
    
    if (mxGetString(prhs[1], CommandLine, 4096))
        FatalError("Cannot unpack command string");
    
    // Separate to argv[] convention
    
    argv[0] = NULL;
    for (pt = strtok(CommandLine, " ");
                pt;
                pt = strtok(NULL, " ")) {
        
                        argv[argc++] = pt;
    }
    
    
    
    // Parse arguments
    HandleSwitches(argc, argv);
    

    nBytesDepth = SizeOfArrayType(prhs[0]);

    OpenTransforms(argc, argv);


    plhs[0] = AllocateOutputArray(prhs[0], OutputChannels);


    ApplyTransforms(prhs[0], plhs[0]);

    CloseTransforms();
    
    // Done!
}