Example #1
0
// Get input from user
static
void GetLine(char* Buffer, const char* frm, ...)
{    
    int res;
    va_list args;

    va_start(args, frm);

    do {
        if (xisatty(stdin)) 
            vfprintf(stderr, frm, args);

        res = scanf("%4095s", Buffer);

        if (res < 0 || toupper(Buffer[0]) == 'Q') { // Quit?

            CloseTransforms();

            if (xisatty(stdin))  
                fprintf(stderr, "Done.\n");

            exit(0);        
        }
    } while (res == 0);

    va_end(args);  
}
Example #2
0
static
void GetLine(char* Buffer)
{    
    scanf("%s", Buffer);
    
    if (toupper(Buffer[0]) == 'Q') { // Quit?

        CloseTransforms();

        if (xisatty(stdin))  
            printf("Done.\n");

        exit(0);        
    }

}
Example #3
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;     
}
Example #4
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!
}