#ifndef JAS_ICC_H
#define JAS_ICC_H
#include <jasper/jas_config.h>
#include <jasper/jas_types.h>
#include <jasper/jas_stream.h>
#ifdef __cplusplus
extern "C" {
#endif
#define JAS_ICC_MAGIC 0x61637370
#define JAS_ICC_HDRLEN 128
#define JAS_ICC_CLAS_IN 0x73636e72
#define JAS_ICC_CLAS_DPY 0x6d6e7472
#define JAS_ICC_CLAS_OUT 0x70727472
#define JAS_ICC_CLAS_LNK 0x6c696e6b
#define JAS_ICC_CLAS_CNV 0x73706163
#define JAS_ICC_CLAS_ABS 0x61627374
#define JAS_ICC_CLAS_NAM 0x6e6d636c
#define JAS_ICC_COLORSPC_XYZ 0x58595a20
#define JAS_ICC_COLORSPC_LAB 0x4c616220
#define JAS_ICC_COLORSPC_LUV 0x4c757620
#define JAS_ICC_COLORSPC_YCBCR 0x59436272
#define JAS_ICC_COLORSPC_YXY 0x59787920
#define JAS_ICC_COLORSPC_RGB 0x52474220
#define JAS_ICC_COLORSPC_GRAY 0x47524159
#define JAS_ICC_COLORSPC_HSV 0x48535620
#define JAS_ICC_COLORSPC_HLS 0x484c5320
#define JAS_ICC_COLORSPC_CMYK 0x434d594b
#define JAS_ICC_COLORSPC_CMY 0x434d5920
#define JAS_ICC_COLORSPC_2 0x32434c52
#define JAS_ICC_COLORSPC_3 0x33434c52
#define JAS_ICC_COLORSPC_4 0x34434c52
#define JAS_ICC_COLORSPC_5 0x35434c52
#define JAS_ICC_COLORSPC_6 0x36434c52
#define JAS_ICC_COLORSPC_7 0x37434c52
#define JAS_ICC_COLORSPC_8 0x38434c52
#define JAS_ICC_COLORSPC_9 0x39434c52
#define JAS_ICC_COLORSPC_10 0x41434c52
#define JAS_ICC_COLORSPC_11 0x42434c52
#define JAS_ICC_COLORSPC_12 0x43434c52
#define JAS_ICC_COLORSPC_13 0x44434c52
#define JAS_ICC_COLORSPC_14 0x45434c52
#define JAS_ICC_COLORSPC_15 0x46434c52
#define JAS_ICC_REFCOLORSPC_XYZ 0x58595a20
#define JAS_ICC_REFCOLORSPC_LAB 0x4c616220
#define JAS_ICC_PLATFORM_APPL 0x4150504c
#define JAS_ICC_PLATFORM_MSFT 0x4d534654
#define JAS_ICC_PLATFORM_SGI 0x53474920
#define JAS_ICC_PLATFORM_SUNW 0x53554e57
#define JAS_ICC_PLATFORM_TGNT 0x54474e54
#define JAS_ICC_FLAGS_EMBED 0x01
#define JAS_ICC_FLAGS_NOSEP 0x02
#define JAS_ICC_ATTR_TRANS 0x01
#define JAS_ICC_ATTR_MATTE 0x02
#define JAS_ICC_INTENT_PER 0
#define JAS_ICC_INTENT_REL 1
#define JAS_ICC_INTENT_SAT 2
#define JAS_ICC_INTENT_ABS 3
#define JAS_ICC_TAG_ATOB0 0x41324230
#define JAS_ICC_TAG_ATOB1 0x41324231
#define JAS_ICC_TAG_ATOB2 0x41324232
#define JAS_ICC_TAG_BLUMATCOL 0x6258595a
#define JAS_ICC_TAG_BLUTRC 0x62545243
#define JAS_ICC_TAG_BTOA0 0x42324130
#define JAS_ICC_TAG_BTOA1 0x42324131
#define JAS_ICC_TAG_BTOA2 0x42324132
#define JAS_ICC_TAG_CALTIME 0x63616c74
#define JAS_ICC_TAG_CHARTARGET 0x74617267
#define JAS_ICC_TAG_CPYRT 0x63707274
#define JAS_ICC_TAG_CRDINFO 0x63726469
#define JAS_ICC_TAG_DEVMAKERDESC 0x646d6e64
#define JAS_ICC_TAG_DEVMODELDESC 0x646d6464
#define JAS_ICC_TAG_DEVSET 0x64657673
#define JAS_ICC_TAG_GAMUT 0x67616d74
#define JAS_ICC_TAG_GRYTRC 0x6b545243
#define JAS_ICC_TAG_GRNMATCOL 0x6758595a
#define JAS_ICC_TAG_GRNTRC 0x67545243
#define JAS_ICC_TAG_LUM 0x6c756d69
#define JAS_ICC_TAG_MEASURE 0x6d656173
#define JAS_ICC_TAG_MEDIABLKPT 0x626b7074
#define JAS_ICC_TAG_MEDIAWHIPT 0x77747074
#define JAS_ICC_TAG_NAMCOLR 0x6e636f6c
#define JAS_ICC_TAG_NAMCOLR2 0x6e636c32
#define JAS_ICC_TAG_OUTRESP 0x72657370
#define JAS_ICC_TAG_PREVIEW0 0x70726530
#define JAS_ICC_TAG_PREVIEW1 0x70726531
#define JAS_ICC_TAG_PREVIEW2 0x70726532
#define JAS_ICC_TAG_PROFDESC 0x64657363
#define JAS_ICC_TAG_PROFSEQDESC 0x70736571
#define JAS_ICC_TAG_PSDCRD0 0x70736430
#define JAS_ICC_TAG_PSCRDD1 0x70736431
#define JAS_ICC_TAG_PSCRDD2 0x70736432
#define JAS_ICC_TAG_PSCRDD3 0x70736433
#define JAS_ICC_TAG_PS2CSA 0x70733273
#define JAS_ICC_TAG_PS2RENINTENT 0x70733269
#define JAS_ICC_TAG_REDMATCOL 0x7258595a
#define JAS_ICC_TAG_REDTRC 0x72545243
#define JAS_ICC_TAG_SCRNGDES 0x73637264
#define JAS_ICC_TAG_SCRNG 0x7363726e
#define JAS_ICC_TAG_TECH 0x74656368
#define JAS_ICC_TAG_UCRBG 0x62666420
#define JAS_ICC_TAG_VIEWCONDDESC 0x76756564
#define JAS_ICC_TAG_VIEWCOND 0x76696577
#define JAS_ICC_TYPE_CRDINFO 0x63726469
#define JAS_ICC_TYPE_CURV 0x63757276
#define JAS_ICC_TYPE_DATA 0x64617461
#define JAS_ICC_TYPE_TIME 0x6474696d
#define JAS_ICC_TYPE_DEVSET 0x64657673
#define JAS_ICC_TYPE_LUT16 0x6d667432
#define JAS_ICC_TYPE_LUT8 0x6d667431
#define JAS_ICC_TYPE_MEASURE 0x6d656173
#define JAS_ICC_TYPE_NAMCOLR 0x6e636f6c
#define JAS_ICC_TYPE_NAMCOLR2 0x6e636c32
#define JAS_ICC_TYPE_PROFSEQDESC 0x70736571
#define JAS_ICC_TYPE_RESPCURVSET16 0x72637332
#define JAS_ICC_TYPE_SF32 0x73663332
#define JAS_ICC_TYPE_SCRNG 0x7363726e
#define JAS_ICC_TYPE_SIG 0x73696720
#define JAS_ICC_TYPE_TXTDESC 0x64657363
#define JAS_ICC_TYPE_TXT 0x74657874
#define JAS_ICC_TYPE_UF32 0x75663332
#define JAS_ICC_TYPE_UCRBG 0x62666420
#define JAS_ICC_TYPE_UI16 0x75693136
#define JAS_ICC_TYPE_UI32 0x75693332
#define JAS_ICC_TYPE_UI8 0x75693038
#define JAS_ICC_TYPE_UI64 0x75693634
#define JAS_ICC_TYPE_VIEWCOND 0x76696577
#define JAS_ICC_TYPE_XYZ 0x58595a20
typedef uint_fast8_t jas_iccuint8_t;
typedef uint_fast16_t jas_iccuint16_t;
typedef uint_fast32_t jas_iccuint32_t;
typedef int_fast32_t jas_iccsint32_t;
typedef int_fast32_t jas_iccs15fixed16_t;
typedef uint_fast32_t jas_iccu16fixed16_t;
typedef uint_fast64_t jas_iccuint64_t;
typedef uint_fast32_t jas_iccsig_t;
typedef jas_iccsig_t jas_icctagsig_t;
typedef jas_iccsig_t jas_icctagtype_t;
typedef jas_iccsig_t jas_iccattrname_t;
typedef struct {
jas_iccuint16_t year;
jas_iccuint16_t month;
jas_iccuint16_t day;
jas_iccuint16_t hour;
jas_iccuint16_t min;
jas_iccuint16_t sec;
} jas_icctime_t;
typedef struct {
jas_iccs15fixed16_t x;
jas_iccs15fixed16_t y;
jas_iccs15fixed16_t z;
} jas_iccxyz_t;
typedef struct {
jas_iccuint32_t numents;
jas_iccuint16_t *ents;
} jas_icccurv_t;
typedef struct {
jas_iccuint32_t asclen;
char *ascdata;
jas_iccuint32_t uclangcode;
jas_iccuint32_t uclen;
uchar *ucdata;
jas_iccuint16_t sccode;
jas_iccuint8_t maclen;
uchar macdata[69];
} jas_icctxtdesc_t;
typedef struct {
char *string;
} jas_icctxt_t;
typedef struct {
jas_iccuint8_t numinchans;
jas_iccuint8_t numoutchans;
jas_iccsint32_t e[3][3];
jas_iccuint8_t clutlen;
jas_iccuint8_t *clut;
jas_iccuint16_t numintabents;
jas_iccuint8_t **intabs;
jas_iccuint8_t *intabsbuf;
jas_iccuint16_t numouttabents;
jas_iccuint8_t **outtabs;
jas_iccuint8_t *outtabsbuf;
} jas_icclut8_t;
typedef struct {
jas_iccuint8_t numinchans;
jas_iccuint8_t numoutchans;
jas_iccsint32_t e[3][3];
jas_iccuint8_t clutlen;
jas_iccuint16_t *clut;
jas_iccuint16_t numintabents;
jas_iccuint16_t **intabs;
jas_iccuint16_t *intabsbuf;
jas_iccuint16_t numouttabents;
jas_iccuint16_t **outtabs;
jas_iccuint16_t *outtabsbuf;
} jas_icclut16_t;
struct jas_iccattrval_s;
typedef struct {
void (*destroy)(struct jas_iccattrval_s *);
int (*copy)(struct jas_iccattrval_s *, struct jas_iccattrval_s *);
int (*input)(struct jas_iccattrval_s *, jas_stream_t *, int);
int (*output)(struct jas_iccattrval_s *, jas_stream_t *);
int (*getsize)(struct jas_iccattrval_s *);
void (*dump)(struct jas_iccattrval_s *, FILE *);
} jas_iccattrvalops_t;
typedef struct jas_iccattrval_s {
int refcnt;
jas_iccsig_t type;
jas_iccattrvalops_t *ops;
union {
jas_iccxyz_t xyz;
jas_icccurv_t curv;
jas_icctxtdesc_t txtdesc;
jas_icctxt_t txt;
jas_icclut8_t lut8;
jas_icclut16_t lut16;
} data;
} jas_iccattrval_t;
typedef struct {
jas_iccuint32_t size;
jas_iccsig_t cmmtype;
jas_iccuint32_t version;
jas_iccsig_t clas;
jas_iccsig_t colorspc;
jas_iccsig_t refcolorspc;
jas_icctime_t ctime;
jas_iccsig_t magic;
jas_iccsig_t platform;
jas_iccuint32_t flags;
jas_iccsig_t maker;
jas_iccsig_t model;
jas_iccuint64_t attr;
jas_iccsig_t intent;
jas_iccxyz_t illum;
jas_iccsig_t creator;
} jas_icchdr_t;
typedef struct {
jas_iccsig_t name;
jas_iccattrval_t *val;
} jas_iccattr_t;
typedef struct {
int numattrs;
int maxattrs;
jas_iccattr_t *attrs;
} jas_iccattrtab_t;
typedef struct jas_icctagtabent_s {
jas_iccuint32_t tag;
jas_iccuint32_t off;
jas_iccuint32_t len;
void *data;
struct jas_icctagtabent_s *first;
} jas_icctagtabent_t;
typedef struct {
jas_iccuint32_t numents;
jas_icctagtabent_t *ents;
} jas_icctagtab_t;
typedef struct {
jas_icchdr_t hdr;
jas_icctagtab_t tagtab;
jas_iccattrtab_t *attrtab;
} jas_iccprof_t;
typedef struct {
jas_iccuint32_t type;
jas_iccattrvalops_t ops;
} jas_iccattrvalinfo_t;
jas_iccprof_t *jas_iccprof_load(jas_stream_t *in);
int jas_iccprof_save(jas_iccprof_t *prof, jas_stream_t *out);
void jas_iccprof_destroy(jas_iccprof_t *prof);
jas_iccattrval_t *jas_iccprof_getattr(jas_iccprof_t *prof,
jas_iccattrname_t name);
int jas_iccprof_setattr(jas_iccprof_t *prof, jas_iccattrname_t name,
jas_iccattrval_t *val);
void jas_iccprof_dump(jas_iccprof_t *prof, FILE *out);
jas_iccprof_t *jas_iccprof_copy(jas_iccprof_t *prof);
int jas_iccprof_gethdr(jas_iccprof_t *prof, jas_icchdr_t *hdr);
int jas_iccprof_sethdr(jas_iccprof_t *prof, jas_icchdr_t *hdr);
void jas_iccattrval_destroy(jas_iccattrval_t *attrval);
void jas_iccattrval_dump(jas_iccattrval_t *attrval, FILE *out);
int jas_iccattrval_allowmodify(jas_iccattrval_t **attrval);
jas_iccattrval_t *jas_iccattrval_clone(jas_iccattrval_t *attrval);
jas_iccattrval_t *jas_iccattrval_create(jas_iccuint32_t type);
void jas_iccattrtab_dump(jas_iccattrtab_t *attrtab, FILE *out);
extern uchar jas_iccprofdata_srgb[];
extern int jas_iccprofdata_srgblen;
extern uchar jas_iccprofdata_sgray[];
extern int jas_iccprofdata_sgraylen;
jas_iccprof_t *jas_iccprof_createfrombuf(uchar *buf, int len);
jas_iccprof_t *jas_iccprof_createfromclrspc(int clrspc);
#ifdef __cplusplus
}
#endif
#endif