/*
**      main include file for ics.library
**
**      (C) Copyright 1997 Wolf Faust
**      All Rights Reserved.
*/

#ifndef _ICS_ICS_H
#define _ICS_ICS_H

#include <inttypes.h>

// Error values 1 up to (including) ICS_ERRMSGLIMIT should not be displayed by application as ICS library already noticed the user
#define ICS_ERRMSGLIMIT 199


//
// Color spaces
//
// The following color spaces are supported.
// Gray, RGB, CMYK, XYZ, Yxy, Lab, generic 3 channel color spaces where
// the profiles defines how to interpret the 3 channels, named color spaces
// which can either be indices into the space or have color names, and
// multichannel spaces with 1 byte per channel upto MAX_COLOR_CHANNELS.
//

#define MAX_COLOR_CHANNELS  8   /* maximum number of color channels supported (mainly, but not only) by HIFI colors */

struct GRAYCOLOR {
    int16_t gray;
};

struct UGRAYCOLOR {
    uint16_t    gray;
};

struct RGBCOLOR {
    int16_t    red;
    int16_t    green;
    int16_t    blue;
};

struct URGBCOLOR {
    uint16_t    red;
    uint16_t    green;
    uint16_t    blue;
};

struct CMYKCOLOR {
    int16_t    cyan;
    int16_t    magenta;
    int16_t    yellow;
    int16_t    black;
};

struct UCMYKCOLOR {
    uint16_t    cyan;
    uint16_t    magenta;
    uint16_t    yellow;
    uint16_t    black;
};

struct XYZCOLOR {
    int16_t    X;
    int16_t    Y;
    int16_t    Z;
};

struct YxyCOLOR {
    int16_t    Y;
    int16_t    x;
    int16_t    y;
};

struct LabCOLOR {
    int16_t    L;
    int16_t    a;
    int16_t    b;
};

struct GENERIC3CHANNEL {
    int16_t    ch1;
    int16_t    ch2;
    int16_t    ch3;
};

struct NAMEDCOLOR {
    int32_t dwIndex;
    PSTR      pName;
};

struct HiFiCOLOR {
    int8_t   channel[MAX_COLOR_CHANNELS];
};

typedef void * HANDLE;

typedef HANDLE HTRANSFORM;      /* handle to color transform object */

typedef union tagCOLOR {
    struct GRAYCOLOR        gray;
    struct UGRAYCOLOR       ugray;
    struct RGBCOLOR         rgb;
    struct URGBCOLOR        urgb;
    struct CMYKCOLOR        cmyk;
    struct UCMYKCOLOR       ucmyk;
    struct XYZCOLOR         XYZ;
    struct YxyCOLOR         Yxy;
    struct LabCOLOR         Lab;
    struct GENERIC3CHANNEL  gen3ch;
    struct NAMEDCOLOR       named;
    struct HiFiCOLOR        hifi;
} COLOR;
typedef COLOR *PCOLOR, *LPCOLOR;

typedef enum {
    COLOR_GRAY       =   1,
    COLOR_UGRAY,
    COLOR_RGB,
    COLOR_URGB,
    COLOR_XYZ,
    COLOR_Yxy,
    COLOR_Lab,
    COLOR_3_CHANNEL,        // int16_t per channel
    COLOR_CMYK,
    COLOR_UCMYK,
    COLOR_5_CHANNEL,        // BYTE per channel
    COLOR_6_CHANNEL,        //      - do -
    COLOR_7_CHANNEL,        //      - do -
    COLOR_8_CHANNEL,        //      - do -
    COLOR_NAMED,
    COLOR_HiFi,
    COLOR_JCh,              // CIECAM 97s JCh color (currently only used internaly by library)
} COLORTYPE;

typedef COLORTYPE *PCOLORTYPE, *LPCOLORTYPE;

//
// Rendering Intents
//

#define INTENT_PERCEPTUAL               0
#define INTENT_RELATIVE_COLORIMETRIC    1
#define INTENT_SATURATION               2
#define INTENT_ABSOLUTE_COLORIMETRIC    3

// Used by SetICSMode()

#define ICS_OFF   1
#define ICS_ON    2
#define ICS_QUERY 3

// Macros to retrieve CMYK values
#define GetKValue(cmyk)      ((uint8_t)(cmyk))
#define GetYValue(cmyk)      ((uint8_t)((cmyk)>> 8))
#define GetMValue(cmyk)      ((uint8_t)((cmyk)>>16))
#define GetCValue(cmyk)      ((uint8_t)((cmyk)>>24))

#define CMYK(c,m,y,k)       ((uint32_t)((((uint8_t)(k)|((int16_t)((uint8_t)(y))<<8))|(((int32_t)(uint8_t)(m))<<16))|(((int32_t)(uint8_t)(c))<<24)))

#define TAG_ICSUSER   ((ULONG)(1L<<31))



// Flags used for ICS_TransferDevices tag
#define ICS_INPUT_DEVICE		0x0001	/* Transform from input (scanner) to device (monitor) profile color */
#define ICS_DEVICE_DEVICE		0x0002	/* Transform from device to device profile color (default) */

// Flags used for ICS_TransferDevices tag

//
// The TagItem ID's (ti_Tag values) for CreateIDCTransform() follow.
// They are values in a TagItem array passed as extension/replacement
// values for the data in the IDC.
// 

// 
// Global basic Tags used supported by various functions
// 


#define ICS_Dummy	(TAG_ICSUSER)	/* 0x80000000	*/

#define ICS_TextAttr  (ICS_Dummy + 0x01)   /* struct TextAttr *, a mono spaced font for use in the ICS gui */
#define ICS_Screen    (ICS_Dummy + 0x02)   /* struct Screen *, Open the gui on the given screen pointer    */


// 
// Tags used for CreateIDCTransform()
// 

#define ICS_TransDummy	(TAG_ICSUSER+0x6000)	/* 0x80006000	*/

#define ICS_TransferDevices     (ICS_TransDummy + 0x01)   /* Describes the source and destination device */
#define ICS_ScanTLCGray         (ICS_TransDummy + 0x02)   /* uint16_t **, Disables TLC correction and the lib will return a (uint16_t *) to the TLC table in the given address so that you can apply the TLC table (download to scanner) */
#define ICS_ScanTLCRed          (ICS_TransDummy + 0x03)   /* uint16_t **, Disables TLC correction and the lib will return a (uint16_t *) to the TLC table in the given address so that you can apply the TLC table (download to scanner) */
#define ICS_ScanTLCGreen        (ICS_TransDummy + 0x04)   /* If specified, you must use all ICS_SCANTLCRED, ICS_SCANTLCGREEN, ICS_SCANTLCBLUE together. */
#define ICS_ScanTLCBlue         (ICS_TransDummy + 0x05)


// 
// Tags used for ICSStatusWin()  (and CreateIDCTransform()) 
// 

#define ICS_StatDummy	(TAG_ICSUSER+0x8000)	/* 0x80008000	*/

#define ICS_StatusOpen  (ICS_StatDummy + 0x01)  /* struct Screen *, Open status window with given screen pointer */
#define ICS_StatusKeep  (ICS_StatDummy + 0x02)  /* BOOL, this flag only makes sense during a CreateIDCTransform() call and leaves the status window open for further use after the lib call */
#define ICS_StatusClose (ICS_StatDummy + 0x03)  /* close status window */
#define ICS_StatusTitle (ICS_StatDummy + 0x04)  /* PSTR, window title of status window */
#define ICS_StatusText  (ICS_StatDummy + 0x05)  /* PSTR, text of status window */
#define ICS_StatusProgress      (ICS_StatDummy + 0x06)  /* uint32_t, percentage complete value */
#define ICS_StatusCheck         (ICS_StatDummy + 0x07)  /* percentage complete value */
#define ICS_StatusDisableAbort  (ICS_StatDummy + 0x08)  /* BOOL, set to true if abort gadget is disabled */
#define ICS_StatusAbortPtr  (ICS_StatDummy + 0x09)  /* uint32_t *, ics stores non-zero if user wants abort into var specified by given pointer */
#define ICS_StatusActivate  (ICS_StatDummy + 0x0a)  /* BOOL, set to true to make the status window the active window */


// 
// Tags used for CreateIDC()
// 

#define ICS_ICDDummy	(TAG_ICSUSER+0xa000)	/* 0x8000a000	*/

#define ICS_APPNAME			    (ICS_ICDDummy + 0x01)   /* const PSTR, name of calling application                   */
#define ICS_APPNAMEVERSION  (ICS_ICDDummy + 0x02)   /* uint32_t, version of calling application                  */
#define ICS_APPICSVERSION	  (ICS_ICDDummy + 0x03)   /* uint32_t, version of ICS library application was made for */
#define ICS_PREFSFILE	      (ICS_ICDDummy + 0x04)   /* const PSTR, complete filename and path with ICS preferences file to load for this IDC handle */
#define ICS_USE     	      (ICS_ICDDummy + 0x05)   /* PRIVATE - DO NOT USE. Set data to NULL */
#define ICS_SAVE     	      (ICS_ICDDummy + 0x06)   /* PRIVATE - DO NOT USE. Set data to NULL */

#endif /* _ICS_ICS_H */
