Path: blob/master/3rdparty/libjasper/jasper/jas_icc.h
16337 views
/*1* Copyright (c) 2002-2003 Michael David Adams.2* All rights reserved.3*/45/* __START_OF_JASPER_LICENSE__6*7* JasPer License Version 2.08*9* Copyright (c) 2001-2006 Michael David Adams10* Copyright (c) 1999-2000 Image Power, Inc.11* Copyright (c) 1999-2000 The University of British Columbia12*13* All rights reserved.14*15* Permission is hereby granted, free of charge, to any person (the16* "User") obtaining a copy of this software and associated documentation17* files (the "Software"), to deal in the Software without restriction,18* including without limitation the rights to use, copy, modify, merge,19* publish, distribute, and/or sell copies of the Software, and to permit20* persons to whom the Software is furnished to do so, subject to the21* following conditions:22*23* 1. The above copyright notices and this permission notice (which24* includes the disclaimer below) shall be included in all copies or25* substantial portions of the Software.26*27* 2. The name of a copyright holder shall not be used to endorse or28* promote products derived from the Software without specific prior29* written permission.30*31* THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS32* LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER33* THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS34* "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING35* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A36* PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO37* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL38* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING39* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,40* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION41* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE42* PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE43* THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.44* EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS45* BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL46* PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS47* GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE48* ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE49* IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL50* SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,51* AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL52* SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH53* THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,54* PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH55* RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY56* EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.57*58* __END_OF_JASPER_LICENSE__59*/6061#ifndef JAS_ICC_H62#define JAS_ICC_H6364#include <jasper/jas_config.h>65#include <jasper/jas_types.h>66#include <jasper/jas_stream.h>6768#ifdef __cplusplus69extern "C" {70#endif7172/* Profile file signature. */73#define JAS_ICC_MAGIC 0x616373707475#define JAS_ICC_HDRLEN 1287677/* Profile/device class signatures. */78#define JAS_ICC_CLAS_IN 0x73636e72 /* input device */79#define JAS_ICC_CLAS_DPY 0x6d6e7472 /* display device */80#define JAS_ICC_CLAS_OUT 0x70727472 /* output device */81#define JAS_ICC_CLAS_LNK 0x6c696e6b /* device link */82#define JAS_ICC_CLAS_CNV 0x73706163 /* color space conversion */83#define JAS_ICC_CLAS_ABS 0x61627374 /* abstract */84#define JAS_ICC_CLAS_NAM 0x6e6d636c /* named color */8586/* Color space signatures. */87#define JAS_ICC_COLORSPC_XYZ 0x58595a20 /* XYZ */88#define JAS_ICC_COLORSPC_LAB 0x4c616220 /* LAB */89#define JAS_ICC_COLORSPC_LUV 0x4c757620 /* LUV */90#define JAS_ICC_COLORSPC_YCBCR 0x59436272 /* YCbCr */91#define JAS_ICC_COLORSPC_YXY 0x59787920 /* Yxy */92#define JAS_ICC_COLORSPC_RGB 0x52474220 /* RGB */93#define JAS_ICC_COLORSPC_GRAY 0x47524159 /* Gray */94#define JAS_ICC_COLORSPC_HSV 0x48535620 /* HSV */95#define JAS_ICC_COLORSPC_HLS 0x484c5320 /* HLS */96#define JAS_ICC_COLORSPC_CMYK 0x434d594b /* CMYK */97#define JAS_ICC_COLORSPC_CMY 0x434d5920 /* CMY */98#define JAS_ICC_COLORSPC_2 0x32434c52 /* 2 channel color */99#define JAS_ICC_COLORSPC_3 0x33434c52 /* 3 channel color */100#define JAS_ICC_COLORSPC_4 0x34434c52 /* 4 channel color */101#define JAS_ICC_COLORSPC_5 0x35434c52 /* 5 channel color */102#define JAS_ICC_COLORSPC_6 0x36434c52 /* 6 channel color */103#define JAS_ICC_COLORSPC_7 0x37434c52 /* 7 channel color */104#define JAS_ICC_COLORSPC_8 0x38434c52 /* 8 channel color */105#define JAS_ICC_COLORSPC_9 0x39434c52 /* 9 channel color */106#define JAS_ICC_COLORSPC_10 0x41434c52 /* 10 channel color */107#define JAS_ICC_COLORSPC_11 0x42434c52 /* 11 channel color */108#define JAS_ICC_COLORSPC_12 0x43434c52 /* 12 channel color */109#define JAS_ICC_COLORSPC_13 0x44434c52 /* 13 channel color */110#define JAS_ICC_COLORSPC_14 0x45434c52 /* 14 channel color */111#define JAS_ICC_COLORSPC_15 0x46434c52 /* 15 channel color */112113/* Profile connection color space (PCS) signatures. */114#define JAS_ICC_REFCOLORSPC_XYZ 0x58595a20 /* CIE XYZ */115#define JAS_ICC_REFCOLORSPC_LAB 0x4c616220 /* CIE Lab */116117/* Primary platform signatures. */118#define JAS_ICC_PLATFORM_APPL 0x4150504c /* Apple Computer */119#define JAS_ICC_PLATFORM_MSFT 0x4d534654 /* Microsoft */120#define JAS_ICC_PLATFORM_SGI 0x53474920 /* Silicon Graphics */121#define JAS_ICC_PLATFORM_SUNW 0x53554e57 /* Sun Microsystems */122#define JAS_ICC_PLATFORM_TGNT 0x54474e54 /* Taligent */123124/* Profile flags. */125#define JAS_ICC_FLAGS_EMBED 0x01 /* embedded */126#define JAS_ICC_FLAGS_NOSEP 0x02 /* no separate use */127128/* Attributes. */129#define JAS_ICC_ATTR_TRANS 0x01 /* transparent */130#define JAS_ICC_ATTR_MATTE 0x02 /* matte */131132/* Rendering intents. */133#define JAS_ICC_INTENT_PER 0 /* perceptual */134#define JAS_ICC_INTENT_REL 1 /* relative colorimetric */135#define JAS_ICC_INTENT_SAT 2 /* saturation */136#define JAS_ICC_INTENT_ABS 3 /* absolute colorimetric */137138/* Tag signatures. */139#define JAS_ICC_TAG_ATOB0 0x41324230 /* */140#define JAS_ICC_TAG_ATOB1 0x41324231 /* */141#define JAS_ICC_TAG_ATOB2 0x41324232 /* */142#define JAS_ICC_TAG_BLUMATCOL 0x6258595a /* */143#define JAS_ICC_TAG_BLUTRC 0x62545243 /* */144#define JAS_ICC_TAG_BTOA0 0x42324130 /* */145#define JAS_ICC_TAG_BTOA1 0x42324131 /* */146#define JAS_ICC_TAG_BTOA2 0x42324132 /* */147#define JAS_ICC_TAG_CALTIME 0x63616c74 /* */148#define JAS_ICC_TAG_CHARTARGET 0x74617267 /* */149#define JAS_ICC_TAG_CPYRT 0x63707274 /* */150#define JAS_ICC_TAG_CRDINFO 0x63726469 /* */151#define JAS_ICC_TAG_DEVMAKERDESC 0x646d6e64 /* */152#define JAS_ICC_TAG_DEVMODELDESC 0x646d6464 /* */153#define JAS_ICC_TAG_DEVSET 0x64657673 /* */154#define JAS_ICC_TAG_GAMUT 0x67616d74 /* */155#define JAS_ICC_TAG_GRYTRC 0x6b545243 /* */156#define JAS_ICC_TAG_GRNMATCOL 0x6758595a /* */157#define JAS_ICC_TAG_GRNTRC 0x67545243 /* */158#define JAS_ICC_TAG_LUM 0x6c756d69 /* */159#define JAS_ICC_TAG_MEASURE 0x6d656173 /* */160#define JAS_ICC_TAG_MEDIABLKPT 0x626b7074 /* */161#define JAS_ICC_TAG_MEDIAWHIPT 0x77747074 /* */162#define JAS_ICC_TAG_NAMCOLR 0x6e636f6c /* */163#define JAS_ICC_TAG_NAMCOLR2 0x6e636c32 /* */164#define JAS_ICC_TAG_OUTRESP 0x72657370 /* */165#define JAS_ICC_TAG_PREVIEW0 0x70726530 /* */166#define JAS_ICC_TAG_PREVIEW1 0x70726531 /* */167#define JAS_ICC_TAG_PREVIEW2 0x70726532 /* */168#define JAS_ICC_TAG_PROFDESC 0x64657363 /* */169#define JAS_ICC_TAG_PROFSEQDESC 0x70736571 /* */170#define JAS_ICC_TAG_PSDCRD0 0x70736430 /* */171#define JAS_ICC_TAG_PSCRDD1 0x70736431 /* */172#define JAS_ICC_TAG_PSCRDD2 0x70736432 /* */173#define JAS_ICC_TAG_PSCRDD3 0x70736433 /* */174#define JAS_ICC_TAG_PS2CSA 0x70733273 /* */175#define JAS_ICC_TAG_PS2RENINTENT 0x70733269 /* */176#define JAS_ICC_TAG_REDMATCOL 0x7258595a /* */177#define JAS_ICC_TAG_REDTRC 0x72545243 /* */178#define JAS_ICC_TAG_SCRNGDES 0x73637264 /* */179#define JAS_ICC_TAG_SCRNG 0x7363726e /* */180#define JAS_ICC_TAG_TECH 0x74656368 /* */181#define JAS_ICC_TAG_UCRBG 0x62666420 /* */182#define JAS_ICC_TAG_VIEWCONDDESC 0x76756564 /* */183#define JAS_ICC_TAG_VIEWCOND 0x76696577 /* */184185/* Type signatures. */186#define JAS_ICC_TYPE_CRDINFO 0x63726469 /* CRD information */187#define JAS_ICC_TYPE_CURV 0x63757276 /* curve */188#define JAS_ICC_TYPE_DATA 0x64617461 /* data */189#define JAS_ICC_TYPE_TIME 0x6474696d /* date/time */190#define JAS_ICC_TYPE_DEVSET 0x64657673 /* device settings */191#define JAS_ICC_TYPE_LUT16 0x6d667432 /* */192#define JAS_ICC_TYPE_LUT8 0x6d667431 /* */193#define JAS_ICC_TYPE_MEASURE 0x6d656173 /* */194#define JAS_ICC_TYPE_NAMCOLR 0x6e636f6c /* */195#define JAS_ICC_TYPE_NAMCOLR2 0x6e636c32 /* */196#define JAS_ICC_TYPE_PROFSEQDESC 0x70736571 /* profile sequence description */197#define JAS_ICC_TYPE_RESPCURVSET16 0x72637332 /* response curve set 16 */198#define JAS_ICC_TYPE_SF32 0x73663332 /* signed 32-bit fixed-point */199#define JAS_ICC_TYPE_SCRNG 0x7363726e /* screening */200#define JAS_ICC_TYPE_SIG 0x73696720 /* signature */201#define JAS_ICC_TYPE_TXTDESC 0x64657363 /* text description */202#define JAS_ICC_TYPE_TXT 0x74657874 /* text */203#define JAS_ICC_TYPE_UF32 0x75663332 /* unsigned 32-bit fixed-point */204#define JAS_ICC_TYPE_UCRBG 0x62666420 /* */205#define JAS_ICC_TYPE_UI16 0x75693136 /* */206#define JAS_ICC_TYPE_UI32 0x75693332 /* */207#define JAS_ICC_TYPE_UI8 0x75693038 /* */208#define JAS_ICC_TYPE_UI64 0x75693634 /* */209#define JAS_ICC_TYPE_VIEWCOND 0x76696577 /* */210#define JAS_ICC_TYPE_XYZ 0x58595a20 /* XYZ */211212typedef uint_fast8_t jas_iccuint8_t;213typedef uint_fast16_t jas_iccuint16_t;214typedef uint_fast32_t jas_iccuint32_t;215typedef int_fast32_t jas_iccsint32_t;216typedef int_fast32_t jas_iccs15fixed16_t;217typedef uint_fast32_t jas_iccu16fixed16_t;218typedef uint_fast64_t jas_iccuint64_t;219typedef uint_fast32_t jas_iccsig_t;220221typedef jas_iccsig_t jas_icctagsig_t;222typedef jas_iccsig_t jas_icctagtype_t;223typedef jas_iccsig_t jas_iccattrname_t;224225/* Date/time type. */226typedef struct {227jas_iccuint16_t year;228jas_iccuint16_t month;229jas_iccuint16_t day;230jas_iccuint16_t hour;231jas_iccuint16_t min;232jas_iccuint16_t sec;233} jas_icctime_t;234235/* XYZ type. */236typedef struct {237jas_iccs15fixed16_t x;238jas_iccs15fixed16_t y;239jas_iccs15fixed16_t z;240} jas_iccxyz_t;241242/* Curve type. */243typedef struct {244jas_iccuint32_t numents;245jas_iccuint16_t *ents;246} jas_icccurv_t;247248/* Text description type. */249typedef struct {250jas_iccuint32_t asclen;251char *ascdata; /* ASCII invariant description */252jas_iccuint32_t uclangcode; /* Unicode language code */253jas_iccuint32_t uclen; /* Unicode localizable description count */254uchar *ucdata; /* Unicode localizable description */255jas_iccuint16_t sccode; /* ScriptCode code */256jas_iccuint8_t maclen; /* Localizable Macintosh description count */257uchar macdata[69]; /* Localizable Macintosh description */258} jas_icctxtdesc_t;259260/* Text type. */261typedef struct {262char *string; /* ASCII character string */263} jas_icctxt_t;264265typedef struct {266jas_iccuint8_t numinchans;267jas_iccuint8_t numoutchans;268jas_iccsint32_t e[3][3];269jas_iccuint8_t clutlen;270jas_iccuint8_t *clut;271jas_iccuint16_t numintabents;272jas_iccuint8_t **intabs;273jas_iccuint8_t *intabsbuf;274jas_iccuint16_t numouttabents;275jas_iccuint8_t **outtabs;276jas_iccuint8_t *outtabsbuf;277} jas_icclut8_t;278279typedef struct {280jas_iccuint8_t numinchans;281jas_iccuint8_t numoutchans;282jas_iccsint32_t e[3][3];283jas_iccuint8_t clutlen;284jas_iccuint16_t *clut;285jas_iccuint16_t numintabents;286jas_iccuint16_t **intabs;287jas_iccuint16_t *intabsbuf;288jas_iccuint16_t numouttabents;289jas_iccuint16_t **outtabs;290jas_iccuint16_t *outtabsbuf;291} jas_icclut16_t;292293struct jas_iccattrval_s;294295typedef struct {296void (*destroy)(struct jas_iccattrval_s *);297int (*copy)(struct jas_iccattrval_s *, struct jas_iccattrval_s *);298int (*input)(struct jas_iccattrval_s *, jas_stream_t *, int);299int (*output)(struct jas_iccattrval_s *, jas_stream_t *);300int (*getsize)(struct jas_iccattrval_s *);301void (*dump)(struct jas_iccattrval_s *, FILE *);302} jas_iccattrvalops_t;303304/* Attribute value type (type and value information). */305typedef struct jas_iccattrval_s {306int refcnt; /* reference count */307jas_iccsig_t type; /* type */308jas_iccattrvalops_t *ops; /* type-dependent operations */309union {310jas_iccxyz_t xyz;311jas_icccurv_t curv;312jas_icctxtdesc_t txtdesc;313jas_icctxt_t txt;314jas_icclut8_t lut8;315jas_icclut16_t lut16;316} data; /* value */317} jas_iccattrval_t;318319/* Header type. */320typedef struct {321jas_iccuint32_t size; /* profile size */322jas_iccsig_t cmmtype; /* CMM type signature */323jas_iccuint32_t version; /* profile version */324jas_iccsig_t clas; /* profile/device class signature */325jas_iccsig_t colorspc; /* color space of data */326jas_iccsig_t refcolorspc; /* profile connection space */327jas_icctime_t ctime; /* creation time */328jas_iccsig_t magic; /* profile file signature */329jas_iccsig_t platform; /* primary platform */330jas_iccuint32_t flags; /* profile flags */331jas_iccsig_t maker; /* device manufacturer signature */332jas_iccsig_t model; /* device model signature */333jas_iccuint64_t attr; /* device setup attributes */334jas_iccsig_t intent; /* rendering intent */335jas_iccxyz_t illum; /* illuminant */336jas_iccsig_t creator; /* profile creator signature */337} jas_icchdr_t;338339typedef struct {340jas_iccsig_t name;341jas_iccattrval_t *val;342} jas_iccattr_t;343344typedef struct {345int numattrs;346int maxattrs;347jas_iccattr_t *attrs;348} jas_iccattrtab_t;349350typedef struct jas_icctagtabent_s {351jas_iccuint32_t tag;352jas_iccuint32_t off;353jas_iccuint32_t len;354void *data;355struct jas_icctagtabent_s *first;356} jas_icctagtabent_t;357358typedef struct {359jas_iccuint32_t numents;360jas_icctagtabent_t *ents;361} jas_icctagtab_t;362363/* ICC profile type. */364typedef struct {365jas_icchdr_t hdr;366jas_icctagtab_t tagtab;367jas_iccattrtab_t *attrtab;368} jas_iccprof_t;369370typedef struct {371jas_iccuint32_t type;372jas_iccattrvalops_t ops;373} jas_iccattrvalinfo_t;374375jas_iccprof_t *jas_iccprof_load(jas_stream_t *in);376int jas_iccprof_save(jas_iccprof_t *prof, jas_stream_t *out);377void jas_iccprof_destroy(jas_iccprof_t *prof);378jas_iccattrval_t *jas_iccprof_getattr(jas_iccprof_t *prof,379jas_iccattrname_t name);380int jas_iccprof_setattr(jas_iccprof_t *prof, jas_iccattrname_t name,381jas_iccattrval_t *val);382void jas_iccprof_dump(jas_iccprof_t *prof, FILE *out);383jas_iccprof_t *jas_iccprof_copy(jas_iccprof_t *prof);384int jas_iccprof_gethdr(jas_iccprof_t *prof, jas_icchdr_t *hdr);385int jas_iccprof_sethdr(jas_iccprof_t *prof, jas_icchdr_t *hdr);386387void jas_iccattrval_destroy(jas_iccattrval_t *attrval);388void jas_iccattrval_dump(jas_iccattrval_t *attrval, FILE *out);389int jas_iccattrval_allowmodify(jas_iccattrval_t **attrval);390jas_iccattrval_t *jas_iccattrval_clone(jas_iccattrval_t *attrval);391jas_iccattrval_t *jas_iccattrval_create(jas_iccuint32_t type);392393void jas_iccattrtab_dump(jas_iccattrtab_t *attrtab, FILE *out);394395extern uchar jas_iccprofdata_srgb[];396extern int jas_iccprofdata_srgblen;397extern uchar jas_iccprofdata_sgray[];398extern int jas_iccprofdata_sgraylen;399jas_iccprof_t *jas_iccprof_createfrombuf(uchar *buf, int len);400jas_iccprof_t *jas_iccprof_createfromclrspc(int clrspc);401402#ifdef __cplusplus403}404#endif405406#endif407408409