Initial commit: ArgyllCMS v3.5.0 and multichannel profiling research

This commit is contained in:
2026-10-31 14:27:14 +03:30
commit 66f664fc82
1828 changed files with 1123613 additions and 0 deletions

BIN
Argyll_V3.5.0/icc/ACES_P3.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/ClayRGB1998.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/DisplayP3.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/EBU3213_PAL.icm Executable file

Binary file not shown.

95
Argyll_V3.5.0/icc/Jamfile Executable file
View File

@@ -0,0 +1,95 @@
# JAM style makefile for icclib and friends
#PREF_CCFLAGS = $(CCOPTFLAG) ; # Turn optimisation on
PREF_CCFLAGS = $(CCDEBUGFLAG) ; # Debugging flags
#PREF_CCFLAGS = $(CCHEAPDEBUG) ; # Heap Debugging flags
PREF_LINKFLAGS = $(LINKDEBUGFLAG) ; # Link debugging flags
#if stdio is not wanted in icclib:
#DEFINES = SEPARATE_STD ;
#Products
Libraries = libicc ;
Executables = iccdump icclu ;
Headers = icc.h ;
Samples = sRGB.icm ClayRGB1998.icm EBU3213_PAL.icm SMPTE_RP145_NTSC.icm Rec709.icm
Rec2020.icm SMPTE431_P3.icm ACES_P3.icm DisplayP3.icm ProPhoto.icm ProPhotoLin.icm lab2lab.icm ;
# Remember to add samples to ref/afiles !
#Install
InstallBin $(DESTDIR)$(PREFIX)/bin : $(Executables) ;
#InstallFile $(DESTDIR)$(PREFIX)/h : $(Headers) ;
#InstallLib $(DESTDIR)$(PREFIX)/lib : $(Libraries) ;
InstallFile $(DESTDIR)$(PREFIX)/$(REFSUBDIR) : $(Samples) ;
# ICC library
Library libicc : icc.c ;
# Executable support if SEPARATED_STD
if SEPARATE_STD in $(DEFINES) {
Objects iccstd.c ;
LINKOBJS = iccstd ; # Link all utilities here with iccstd
}
# Link all utilities here with libicc
LINKLIBS = libicc ;
# All utils are made from a single source file
MainsFromSources icctest.c lutest.c iccdump.c icclu.c iccrw.c ;
if [ GLOB [ NormPaths . ] : petest.c ] {
MainsFromSources petest.c ;
}
if [ GLOB [ NormPaths . ] : prorun.c ] {
NDepends install : prorun ;
MainsFromSources prorun.c ;
}
if [ GLOB [ NormPaths . ] : protest.c ] {
NDepends install : protest ;
MainsFromSources protest.c ;
}
# This is an example program for making a matrix display profile
MainsFromSources mkDispProf.c ;
#MainsFromSources t.c ;
if [ GLOB [ NormPaths . ] : mkPRMGsrc.c ] {
MainsFromSources mkPRMGsrc.c ;
}
if $(BUILD_JUNK) {
HDRS += ../plot ;
LINKLIBS += ../plot/libvrml ;
#Monotonic behaviour checker
# MainsFromSources mcheck.c ;
# MainsFromSources tt.c ;
MainsFromSources mksRGB.c ;
# MainsFromSources mkscRGB.c ;
MainsFromSources mkAdobeRGB.c ;
MainsFromSources mkEBU3213.c ;
MainsFromSources mkSMPTERP145.c ;
MainsFromSources mklab2lab.c ;
MainsFromSources mkRec709.c ;
MainsFromSources mkRec2020.c ;
MainsFromSources mkSMPTE431_P3.c ;
MainsFromSources mkACES_P3.c ;
MainsFromSources mkDisplayP3.c ;
MainsFromSources mkProPhoto.c ;
# MainsFromSources icm2ary.c ;
# Check library is compatible with C++
Main cppcheck : cppcheck.cpp ;
# check CIEDE2000
MainsFromSources testDE2K.c ;
}

22
Argyll_V3.5.0/icc/License4.txt Executable file
View File

@@ -0,0 +1,22 @@
*************************************************************************
Copyright (c) 1997-2023 Graeme W. Gill
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*************************************************************************

86
Argyll_V3.5.0/icc/Makefile Executable file
View File

@@ -0,0 +1,86 @@
# UNIX style makefile, for icclib and friends.
# "include" the right environment for your system,
# by uncommenting the appropriate line:
# Microsoft C++, WinNT setup
include Makefile.WNT
# Generic UNIX setup
#include Makefile.UNIX
# Apple OSX
#include Makefile.OSX
###############################
#Compile with separate stdio
#CCDEFINES = $(DEFFLAG)SEPARATE_STD
#Set optimisation on
CCFLAGS = $(CCFLAGSDEF) $(CCOPTFLAG) $(CCDEFINES)
#Set debugging on
#CCFLAGS = $(CCFLAGSDEF) $(CCDEBUGFLAG) $(CCDEFINES)
STDHDRS = $(STDHDRSDEF)
LINKFLAGS = $(LINKFLAGSDEF) $(LINKDEBUGFLAG)
all:: libicc$(SUFLIB) icctest$(SUFEXE) lutest$(SUFEXE) icclu$(SUFEXE) iccdump$(SUFEXE) iccrw$(SUFEXE) mkDispProf$(SUFEXE)
icc$(SUFOBJ): icc.c icc.h
$(CC) $(CCOF)icc$(SUFOBJ) icc.c
libicc$(SUFLIB): icc$(SUFOBJ)
$(LIBU) $(LIBOF)libicc$(SUFLIB) icc$(SUFOBJ)
$(RANLIB) libicc$(SUFLIB)
# Separate for executables
iccstd$(SUFOBJ): iccstd.c icc.h
$(CC) $(CCOF)iccstd$(SUFOBJ) iccstd.c
icctest$(SUFOBJ): icctest.c icc.h
$(CC) $(CCOF)icctest$(SUFOBJ) icctest.c
icctest$(SUFEXE): icctest$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)icctest$(SUFEXE) icctest$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
lutest$(SUFOBJ): lutest.c icc.h
$(CC) $(CCOF)lutest$(SUFOBJ) lutest.c
lutest$(SUFEXE): lutest$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)lutest$(SUFEXE) lutest$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
icclu$(SUFOBJ): icclu.c icc.h
$(CC) $(CCOF)icclu$(SUFOBJ) icclu.c
icclu$(SUFEXE): icclu$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)icclu$(SUFEXE) icclu$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
iccdump$(SUFOBJ): iccdump.c icc.h
$(CC) $(CCOF)iccdump$(SUFOBJ) iccdump.c
iccdump$(SUFEXE): iccdump$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)iccdump$(SUFEXE) iccdump$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
iccrw$(SUFOBJ): iccrw.c icc.h
$(CC) $(CCOF)iccrw$(SUFOBJ) iccrw.c
iccrw$(SUFEXE): iccrw$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)iccrw$(SUFEXE) iccrw$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
mkDispProf$(SUFOBJ): mkDispProf.c icc.h
$(CC) $(CCOF)mkDispProf$(SUFOBJ) mkDispProf.c
mkDispProf$(SUFEXE): mkDispProf$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)
$(LINK) $(LINKOF)mkDispProf$(SUFEXE) mkDispProf$(SUFOBJ) iccstd$(SUFOBJ) libicc$(SUFLIB)

38
Argyll_V3.5.0/icc/Makefile.OSX Executable file
View File

@@ -0,0 +1,38 @@
# MAC OSX, derived from UNIX setup
SLASH = /
SUFLIB = .a
SUFOBJ = .o
SUFEXE =
CMDSEP = ;
INCFLAG = -I
DEFFLAG = -D
UNDEFFLAG = "-u _"
CCOPTFLAG = -O
CCDEBUGFLAG = -g
CCPROFFLAG =
LINKDEBUGFLAG =
LINKPROFFLAG =
STDHDRSDEF = /usr/include
MAKEU = make
LIBU = ar -r
LIBOF =
RANLIB = ranlib
AS = as
CCFLAGSDEF = -DUNIX -c
CC = cc $(CCFLAGS) $(INCFLAG)$(STDHDRS)
CCOF = -o
LINKFLAGSDEF = -lm
LINKLIBS =
LINK = cc $(LINKFLAGS) $(LINKLIBS)
LINKOF = -o
.SUFFIXES:
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
.c$(SUFOBJ):
$(CC) $(CCOF)$*$(SUFOBJ) $<

38
Argyll_V3.5.0/icc/Makefile.UNIX Executable file
View File

@@ -0,0 +1,38 @@
# Generic UNIX setup
SLASH = /
SUFLIB = .a
SUFOBJ = .o
SUFEXE =
CMDSEP = ;
INCFLAG = -I
DEFFLAG = -D
UNDEFFLAG = "-u _"
CCOPTFLAG = -O
CCDEBUGFLAG = -g
CCPROFFLAG =
LINKDEBUGFLAG =
LINKPROFFLAG =
STDHDRSDEF = /usr/include
MAKEU = make
LIBU = ar -r
LIBOF = -o
RANLIB = echo
AS = as
CCFLAGSDEF = -DUNIX -c
CC = cc $(CCFLAGS) $(INCFLAG)$(STDHDRS)
CCOF = -o
LINKFLAGSDEF = -lm
LINKLIBS =
LINK = cc $(LINKFLAGS) $(LINKLIBS)
LINKOF = -o
.SUFFIXES:
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
.c$(SUFOBJ):
$(CC) $(CCOF)$*$(SUFOBJ) $<

38
Argyll_V3.5.0/icc/Makefile.WNT Executable file
View File

@@ -0,0 +1,38 @@
# Microsoft C++, WinNT setup
SLASH = \
SUFLIB = .lib
SUFOBJ = .obj
SUFEXE = .exe
CMDSEP = &
INCFLAG = /I
DEFFLAG = /D
UNDEFFLAG = "/u _"
CCOPTFLAG = /Ox /GB
CCDEBUGFLAG = /Z7 /Od
CCPROFFLAG = /Z7
LINKDEBUGFLAG = /DEBUG
LINKPROFFLAG = /PROFILE
STDHDRSDEF = $(MSVCNT)\include
MAKEU = nmake
LIBU = lib
LIBOF = /OUT:
RANLIB = rem
AS = masm386
CCFLAGSDEF = /DNT /c
CC = cl /nologo $(CCFLAGS) $(INCFLAG)$(STDHDRS)
CCOF = /Fo
LINKLIBS = $(MSVCNT)/lib/user32.lib $(MSVCNT)/lib/gdi32.lib
LINKFLAGSDEF = /link /INCREMENTAL:NO
LINK = link $(LINKFLAGS)
LINKOF = /OUT:
.SUFFIXES:
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
.c$(SUFOBJ):
$(CC) $(CCOF)$*$(SUFOBJ) $<

BIN
Argyll_V3.5.0/icc/ProPhoto.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/ProPhotoLin.icm Executable file

Binary file not shown.

144
Argyll_V3.5.0/icc/Readme.txt Executable file
View File

@@ -0,0 +1,144 @@
ICC profile I/O library (icclib), README file
---------------------------------------------
This version is part of ArgyllCMS
-------------------------------------------
Date 22 September 2013, Version 2.15
This distribution contains source code which implements the reading and
writing of color profile files that conform to the International Color
Consortium (ICC) Profile Format Specification, Version 3.4.
For more information about the ICC, and for copies of the specification,
please refer to <http://www.color.org/>
(Note that this software is written from the ICC V3.4 standard, but the
software and its author are not affiliated with, or otherwise connected
with the ICC.)
The ICC profile I/O library archive is kept at <http://www.argyllcms.com/>
Motivation
Color is still very much a black art to many programmers dealing with
computer graphics. The ICC Profile Format is an industry attempt to provide
an interchange format to help solve the problems of specifying color, and
in transferring color graphics from, and between systems and devices.
Although the ICC format has been around a number of years, and has long
been adopted by companies in the business of providing systems for
publishing and printing, and is now widely used as part of commercial
operating system support for device independent color, its uptake in the
general world of computer graphics has been slow.
The writing of this library was prompted by my private and professional
enthusiasm for computer graphics, and color. Inspired by other examples of
freely usable software (notably the Independent JPEG Group's free JPEG
software, and Sam Leffler's TIFF library), I have decided to make this
library available under similar terms. I hope that this library will
provide a starting point for including ICC profile support more widely that
is currently the case, particularly in open source code projects.
Overview
This package contains a C software implementation of the ICC Profile
Format, Version 3.4. The ICC Profile Format attempts to provide a
cross-platform device profile format, that can be used to translate color
data created on one device into another device's native color space. For a
fuller explanation of what the ICC Profile Format is all about, please
refer to http://www.color.org, and the profile specification.
In summary this library provides:
* Full source code, free for commercial and non-commercial use.
* Support for all version 3.4 header elements, Tags and Tag Types.
* Conversion to/from machine native representation of all data
types.
* Support for user defined Tags.
* Support for adding/deleting Tags.
* Support for Tag type sharing within a file (often used for
sharing LUTs amongst intents).
* Support for reading/writing embedded profiles, including from/to
a memory buffer, rather than a file.
* Provides a single function for transforming color values through
a profile, including support for intents, forward and reverse
transforms, gamut lookup or preview lookup.
* Provides support and code examples for creating all profile
types, monochrome, matrix and Lut.
* Attempts to be platform neutral, and flexibility in its use of
system file and memory sub-systems.
* Loads Tag Types on demand to conserve memory space.
Package contents:
icclib.zip ZIP archive of the following files
README.txt This file.
License4.txt Important! - Permissions for use of this package.
icc.c Library source file.
iccstd.c Library source that uses stdio and malloc system calls.
icc.h Library include file. Note machine dependent defines.
Includes iccV42.h.
iccV42.h Standard ICC header file modified up to Version 4.2 spec.
iccdump.c Program that dumps ASCII description of a profile.
icclu.c Program that allows interactive or batch translation of
color values though a profile.
icctest.c Basic library tag Read/Write example and regression test
code.
lutest.c Color lookup regression test code, and example for creating
color profiles.
iccrw.c Source code skeleton for reading and then re-writing a
profile.
Jamfile JAM style "makefile" see
http://www.perforce.com/jam/jam.html
Makefile Generic style makefile. Edit this to select the appropriate
system makefile rules.
Makefile.IBMNTMakefile ruleset for Windows NT using the IBM compiler.
Makefile.OSX Makefile ruleset for Mac OSX environment.
Makefile.UNIX Makefile ruleset for Linux style environment.
Makefile.WNT Makefile ruleset for Windows NT using the Microsoft Visual
C++ compiler.
Style
For handling convenience, I have included all the library source code in
two files. The down side is that they are both hard to read and navigate
through. The code could do with some cleaning up and rearrangement, to make
clear the distinction between public and private elements. (C++ would help
here, but is less portable.) The code attempts to be ANSI C compliant,
written in an object oriented style. A tutorial on how to use the library
would also be a good thing !
The best way to learn how to use the library, is to take a look at
icctest.c, lutest.c and iccrw.c. The first is used to test writing and
reading to every type of element, with every possible variation of usage.
You will need a copy of the ICC spec. handy to understand what it all
means. The second source file specifically creates and then tests various
types of profiles, including monochrome, matrix and Lut style profiles. The
last is a source code skeleton, that reads a profile completely into
memory, and then writes it out again to a different file.
With the release of version 2.00 of icclib, the library is now as useful as
it is likely to be, allowing convenient color conversion between PCS
(profile connection spaces, either XYZ or Lab) and device specific color
spaces. The library does not attempt to be a complete color management
system however, lacking profile creation and linking functionality. Icclib
is part of the Argyll CMS, which does attempt to be a complete color
management system. Argyll can be used as a more realistic example of the
use of icclib. I plan at some stage to upgrade icclib to be compatible with
the recently released ICC V4 spec., but will probably get around to this
sometime after the next major release of Argyll.
I welcome feedback, positive or negative, so please mail me at
Graeme at argyllcms dot com
Graeme Gill

BIN
Argyll_V3.5.0/icc/Rec2020.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/Rec709.icm Executable file

Binary file not shown.

BIN
Argyll_V3.5.0/icc/SMPTE431_P3.icm Executable file

Binary file not shown.

Binary file not shown.

40
Argyll_V3.5.0/icc/afiles Executable file
View File

@@ -0,0 +1,40 @@
Readme.txt
License4.txt
todo.txt
log.txt
Jamfile
Makefile
Makefile.WNT
Makefile.UNIX
Makefile.OSX
afiles
iccV44.h
iccstd.c
icc.h
icc.c
icc_pe.h
icc_pe.c
icc_xf.h
icc_xf.c
icc_util.h
icc_util.c
iccdump.c
icclu.c
iccrw.c
icctest.c
lutest.c
mcheck.c
testDE2K.c
mkDispProf.c
sRGB.icm
ClayRGB1998.icm
lab2lab.icm
EBU3213_PAL.icm
SMPTE_RP145_NTSC.icm
Rec709.icm
Rec2020.icm
SMPTE431_P3.icm
ProPhoto.icm
ProPhotoLin.icm
DisplayP3.icm
ACES_P3.icm

12182
Argyll_V3.5.0/icc/icc.c Normal file

File diff suppressed because it is too large Load Diff

2689
Argyll_V3.5.0/icc/icc.h Normal file

File diff suppressed because it is too large Load Diff

637
Argyll_V3.5.0/icc/iccV44.h Normal file
View File

@@ -0,0 +1,637 @@
/*
* This file started out as the standard ICC header provided by
* the ICC. Since this file no longer seems to be maintained,
* I've added new entries from the ICC spec., but dropped
* things that are not needed for icclib.
*
* This version of the header file corresponds to the profile
* Specification ICC.1:2022 (Version 4.4.0)
*
* All header file entries are pre-fixed with "ic" to help
* avoid name space collisions. Signatures are pre-fixed with
* icSig. icclib specific items are prefixed "icm".
*
* Version numbers used within file are file format version numbers,
* not spec. version numbers.
*
* Portions of this file are Copyright 2004 - 2022 Graeme W. Gill,
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*
* Graeme Gill.
*/
/* Header file guard bands */
#ifndef ICCV44_H
#define ICCV44_H
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************
Copyright (c) 1994-1998 SunSoft, Inc.
Rights Reserved
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restrict-
ion, including without limitation the rights to use, copy, modify,
merge, publish distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-
INFRINGEMENT. IN NO EVENT SHALL SUNSOFT, INC. OR ITS PARENT
COMPANY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of SunSoft, Inc.
shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without written
authorization from SunSoft Inc.
******************************************************************/
/*
Spec name/version/file version relationship.
Spec. Name Spec. Version ICC File Version
---------- ------------- ----------------
ICC.1:2022 4.4 4.4.0
ICC.1:2010 4.3 4.3.0
ICC.1:2004-10 4.2 4.2.0
ICC.1:2003-09 4.1 4.1.0
ICC.1:2001-12 4.0 4.0.0
ICC.1:2001-04 (3.7?) 2.4.0
ICC.1A:1999-04 (3.6?) 2.3.0
ICC.1:1998-09 (3.5?) 2.2.0
(Version 3.4) 3.4 2.1.0 (a)
(Version 3.3) 3.3 2.1.0
(Version 3.2) 3.2 2.0.0 (b) [Assumed to be official V2.0]
(Version 3.01) 3.01 2.0.0 (a) [Preliminary]
(Version 3.0) 3.0 2.0.0
*/
#define icMaxTagVal 0xFFFFFFFF
#define icAlignSize 4
/*------------------------------------------------------------------------*/
/*
* Defines used in the specification
*/
#define icMagicNumber 0x61637370 /* 'acsp' */
#define icVersionNumberV20 0x02000000 /* 2.0.0 BCD */
#define icVersionNumberV21 0x02100000 /* 2.1.0 BCD */
#define icVersionNumberV22 0x02200000 /* 2.2.0 BCD */
#define icVersionNumberV23 0x02300000 /* 2.3.0 BCD */
#define icVersionNumberV24 0x02400000 /* 2.4.0 BCD */
#define icVersionNumberV40 0x04000000 /* 4.0.0 BCD */
#define icVersionNumberV41 0x04100000 /* 4.1.0 BCD */
#define icVersionNumberV42 0x04200000 /* 4.2.0 BCD */
#define icVersionNumberV43 0x04300000 /* 4.3.0 BCD */
#define icVersionNumberV44 0x04400000 /* 4.4.0 BCD */
/* Screening Encodings */
typedef unsigned int icScreening;
#define icPrtrDefaultScreensFalse 0x00000000 /* Bit pos 0 */
#define icPrtrDefaultScreensTrue 0x00000001 /* Bit pos 0 */
#define icLinesPerInch 0x00000002 /* Bit pos 1 */
#define icLinesPerCm 0x00000000 /* Bit pos 1 */
/*
* Device attributes, currently defined values correspond
* to the least-significant 4 bytes of the 8 byte attribute
* quantity, see the header for their location.
*/
typedef unsigned int icDeviceAttributes; /* (the bottom 32 bits) */
#define icReflective 0x00000000 /* Bit pos 0 */
#define icTransparency 0x00000001 /* Bit pos 0 */
#define icGlossy 0x00000000 /* Bit pos 1 */
#define icMatte 0x00000002 /* Bit pos 1 */
#define icPositive 0x00000000 /* Bit pos 2 */
#define icNegative 0x00000004 /* Bit pos 2 */
#define icColor 0x00000000 /* Bit pos 3 */
#define icBlackAndWhite 0x00000008 /* Bit pos 3 */
/*
* Profile header flags, the least-significant 16 bits are reserved
* for consortium use.
*/
typedef unsigned int icProfileFlags;
#define icEmbeddedProfileFalse 0x00000000 /* Bit pos 0 */
#define icEmbeddedProfileTrue 0x00000001 /* Bit pos 0 */
#define icUseAnywhere 0x00000000 /* Bit pos 1 */
#define icUseWithEmbeddedDataOnly 0x00000002 /* Bit pos 1 */
/* Ascii or Binary data */
typedef unsigned int icAsciiOrBinary;
#define icAsciiData 0x00000000
#define icBinaryData 0x00000001
/* Video card gamma formats (ColorSync 2.5 specific) */
typedef unsigned int icVideoCardGammaFormat;
#define icVideoCardGammaTable 0x00000000
#define icVideoCardGammaFormula 0x00000001
typedef unsigned int icSig; /* Generic sig */
/*------------------------------------------------------------------------*/
/* public tags and sizes (+ version notes) */
typedef enum {
icSigAToB0Tag = 0x41324230, /* 'A2B0' */
icSigAToB1Tag = 0x41324231, /* 'A2B1' */
icSigAToB2Tag = 0x41324232, /* 'A2B2' */
icSigBlueMatrixColumnTag = 0x6258595A, /* 'bXYZ' */
icSigBlueTRCTag = 0x62545243, /* 'bTRC' */
icSigBToA0Tag = 0x42324130, /* 'B2A0' */
icSigBToA1Tag = 0x42324131, /* 'B2A1' */
icSigBToA2Tag = 0x42324132, /* 'B2A2' */
icSigBToD0Tag = 0x42324430, /* 'B2D0' V4.3+ */
icSigBToD1Tag = 0x42324431, /* 'B2D1' V4.3+ */
icSigBToD2Tag = 0x42324432, /* 'B2D2' V4.3+ */
icSigBToD3Tag = 0x42324433, /* 'B2D3' V4.3+ */
icSigCalibrationDateTimeTag = 0x63616C74, /* 'calt' */
icSigCharTargetTag = 0x74617267, /* 'targ' */
icSigChromaticAdaptationTag = 0x63686164, /* 'chad' V2.4+ */
icSigChromaticityTag = 0x6368726D, /* 'chrm' V2.3+ */
icSigCicpTag = 0x63696370, /* 'cicp' V4.4+ */
icSigColorantOrderTag = 0x636C726F, /* 'clro' V4.0+ */
icSigColorantTableTag = 0x636C7274, /* 'clrt' V4.0+ */
icSigColorantTableOutTag = 0x636C6F74, /* 'clot' V4.0+ */
icSigColorimetricIntentImageStateTag = 0x63696973, /* 'ciis' V4.3+ */
icSigCopyrightTag = 0x63707274, /* 'cprt' */
icSigCrdInfoTag = 0x63726469, /* 'crdi' V2.1 - V4.0 */
icSigDataTag = 0x64617461, /* 'data' ???? */
icSigDateTimeTag = 0x6474696D, /* 'dtim' ???? */
icSigDeviceMfgDescTag = 0x646D6E64, /* 'dmnd' */
icSigDeviceModelDescTag = 0x646D6464, /* 'dmdd' */
icSigDeviceSettingsTag = 0x64657673, /* 'devs' V2.2 - V4.0 */
icSigDToB0Tag = 0x44324230, /* 'D2B0' V4.3+ */
icSigDToB1Tag = 0x44324231, /* 'D2B1' V4.3+ */
icSigDToB2Tag = 0x44324232, /* 'D2B2' V4.3+ */
icSigDToB3Tag = 0x44324233, /* 'D2B3' V4.3+ */
icSigGamutTag = 0x67616D74, /* 'gamt' */
icSigGrayTRCTag = 0x6b545243, /* 'kTRC' */
icSigGreenMatrixColumnTag = 0x6758595A, /* 'gXYZ' */
icSigGreenTRCTag = 0x67545243, /* 'gTRC' */
icSigLuminanceTag = 0x6C756d69, /* 'lumi' */
icSigMeasurementTag = 0x6D656173, /* 'meas' */
icSigMetadataTag = 0x6d657461, /* 'meta' V4.4+ */
icSigMediaBlackPointTag = 0x626B7074, /* 'bkpt' V2.0 - V4.2 */
icSigMediaWhitePointTag = 0x77747074, /* 'wtpt' */
icSigNamedColorTag = 0x6E636f6C, /* 'ncol' V2.0 - V2.0*/
icSigNamedColor2Tag = 0x6E636C32, /* 'ncl2' V2.1+ */
icSigOutputResponseTag = 0x72657370, /* 'resp' V2.2+ */
icSigPerceptualRenderingIntentGamutTag = 0x72696730, /* 'rig0' V4.3+ */
icSigPreview0Tag = 0x70726530, /* 'pre0' */
icSigPreview1Tag = 0x70726531, /* 'pre1' */
icSigPreview2Tag = 0x70726532, /* 'pre2' */
icSigProfileDescriptionTag = 0x64657363, /* 'desc' */
icSigProfileSequenceDescTag = 0x70736571, /* 'pseq' */
icSigProfileSequenceIdentifierTag = 0x70736964, /* 'psid' V4.3+ */
icSigPs2CRD0Tag = 0x70736430, /* 'psd0' V2.0 - V4.0 */
icSigPs2CRD1Tag = 0x70736431, /* 'psd1' V2.0 - V4.0 */
icSigPs2CRD2Tag = 0x70736432, /* 'psd2' V2.0 - V4.0 */
icSigPs2CRD3Tag = 0x70736433, /* 'psd3' V2.0 - V4.0 */
icSigPs2CSATag = 0x70733273, /* 'ps2s' V2.0 - V4.0 */
icSigPs2RenderingIntentTag = 0x70733269, /* 'ps2i' V2.0 - V4.0 */
icSigRedMatrixColumnTag = 0x7258595A, /* 'rXYZ' */
icSigRedTRCTag = 0x72545243, /* 'rTRC' */
icSigSaturationRenderingIntentGamutTag = 0x72696732, /* 'rig2' V4.3+ */
icSigScreeningDescTag = 0x73637264, /* 'scrd' V2.0 - V4.0 */
icSigScreeningTag = 0x7363726E, /* 'scrn' V2.0 - V4.0 */
icSigTechnologyTag = 0x74656368, /* 'tech' */
icSigUcrBgTag = 0x62666420, /* 'bfd ' V2.0 - V4.0 */
icSigVideoCardGammaTag = 0x76636774, /* 'vcgt' ColorSync 2.5+ */
icSigViewingCondDescTag = 0x76756564, /* 'vued' */
icSigViewingConditionsTag = 0x76696577, /* 'view' */
icMaxEnumTag = icMaxTagVal
} icTagSignature;
/* Aliases for backwards compatibility */
#define icSigBlueColorantTag icSigBlueMatrixColumnTag /* V2.0 - V2.4 */
#define icSigGreenColorantTag icSigGreenMatrixColumnTag /* V2.0 - V2.4 */
#define icSigRedColorantTag icSigRedMatrixColumnTag /* V2.0 - V2.4 */
/* tag type signatures (+ version notes) */
typedef enum {
icSigChromaticityType = 0x6368726D, /* 'chrm' V2.3+ */
icSigCicpType = 0x63696370, /* 'cicp' V4.4+ */
icSigColorantOrderType = 0x636C726F, /* 'clro' V4.0+ */
icSigColorantTableType = 0x636C7274, /* 'clrt' V4.0+ */
icSigCrdInfoType = 0x63726469, /* 'crdi' V2.1 - V4.0 */
icSigCurveType = 0x63757276, /* 'curv' */
icSigDataType = 0x64617461, /* 'data' */
icSigDateTimeType = 0x6474696D, /* 'dtim' */
icSigDictType = 0x64696374, /* 'dict' V4.4+ */
icSigDeviceSettingsType = 0x64657673, /* 'devs' V2.2 - V4.0 */
icSigLut16Type = 0x6d667432, /* 'mft2' */
icSigLut8Type = 0x6d667431, /* 'mft1' */
icSigLutAToBType = 0x6d414220, /* 'mAB ' V4.0+ */
icSigLutBToAType = 0x6d424120, /* 'mBA ' V4.0+ */
icSigMeasurementType = 0x6D656173, /* 'meas' */
icSigMultiLocalizedUnicodeType = 0x6D6C7563, /* 'mluc' V4.0+ */
icSigMultiProcessElementsType = 0x6D706574, /* 'mpet' V4.3+ */
icSigNamedColorType = 0x6E636f6C, /* 'ncol' V2.0 - V2.4 (deprecated) */
icSigNamedColor2Type = 0x6E636C32, /* 'ncl2' V2.0+ */
icSigParametricCurveType = 0x70617261, /* 'para' V4.0+ */
icSigProfileSequenceDescType = 0x70736571, /* 'pseq' */
icSigProfileSequenceIdentifierType = 0x70736964, /* 'psid' V4.3+ */
icSigResponseCurveSet16Type = 0x72637332, /* 'rcs2' V2.2+ */
icSigS15Fixed16ArrayType = 0x73663332, /* 'sf32' */
icSigScreeningType = 0x7363726E, /* 'scrn' V2.0 - V4.0 */
icSigSignatureType = 0x73696720, /* 'sig ' */
icSigTextType = 0x74657874, /* 'text' */
icSigTextDescriptionType = 0x64657363, /* 'desc' V2.0 - V2.4 */
icSigU16Fixed16ArrayType = 0x75663332, /* 'uf32' */
icSigUcrBgType = 0x62666420, /* 'bfd ' V2.0 - V4.0 */
icSigUInt16ArrayType = 0x75693136, /* 'ui16' */
icSigUInt32ArrayType = 0x75693332, /* 'ui32' */
icSigUInt64ArrayType = 0x75693634, /* 'ui64' */
icSigUInt8ArrayType = 0x75693038, /* 'ui08' */
icSigVideoCardGammaType = 0x76636774, /* 'vcgt' ColorSync 2.5+ */
icSigViewingConditionsType = 0x76696577, /* 'view' */
icSigXYZType = 0x58595A20, /* 'XYZ ' */
/* MultiProcessElements sub-tagtypes */
icSigCurveSetElement = 0x63767374, /* 'cvst' V4.3+ */
icSigOneDCurveEncoding = 0x63757266, /* 'curf' V4.3+ */
icSigFormulaCurveSegEncoding = 0x70617266, /* 'parf' V4.3+ */
icSigSampledCurveSegEncoding = 0x73616D66, /* 'samf' V4.3+ */
icSigMatrixElement = 0x6D617466, /* 'matf' V4.3+ */
icSigCLUTElement = 0x636C7574, /* 'clut' V4.3+ */
icSigBACSElement = 0x62414353, /* 'bACS' V4.3+ */
icSigEACSElement = 0x65414353, /* 'eACS’ V4.3+ */
icMaxEnumTagType = icMaxTagVal
} icTagTypeSignature;
/* Aliases */
#define icSigXYZArrayType icSigXYZType
/*
* Color Space Signatures
* Note that only icSigXYZData and icSigLabData are valid
* Profile Connection Spaces (PCSs)
*/
typedef enum {
/* PCS & Non-Dev */
icSigXYZData = 0x58595A20, /* 'XYZ ' */
icSigLabData = 0x4C616220, /* 'Lab ' */
/* Non-Dev */
icSigLuvData = 0x4C757620, /* 'Luv ' */
icSigYxyData = 0x59787920, /* 'Yxy ' */
/* Dev (== N-component) */
icSigYCbCrData = 0x59436272, /* 'YCbr' */
icSigRgbData = 0x52474220, /* 'RGB ' */
icSigGrayData = 0x47524159, /* 'GRAY' */
icSigHsvData = 0x48535620, /* 'HSV ' */
icSigHlsData = 0x484C5320, /* 'HLS ' */
icSigCmykData = 0x434D594B, /* 'CMYK' */
icSigCmyData = 0x434D5920, /* 'CMY ' */
/* Dev (== N-component) & N-Color */
icSig2colorData = 0x32434C52, /* '2CLR' V2.1+ */
icSig3colorData = 0x33434C52, /* '3CLR' V2.1+ */
icSig4colorData = 0x34434C52, /* '4CLR' V2.1+ */
icSig5colorData = 0x35434C52, /* '5CLR' V2.1+ */
icSig6colorData = 0x36434C52, /* '6CLR' V2.1+ */
icSig7colorData = 0x37434C52, /* '7CLR' V2.1+ */
icSig8colorData = 0x38434C52, /* '8CLR' V2.1+ */
icSig9colorData = 0x39434C52, /* '9CLR' V2.1+ */
icSig10colorData = 0x41434C52, /* 'ACLR' V2.1+ */
icSig11colorData = 0x42434C52, /* 'BCLR' V2.1+ */
icSig12colorData = 0x43434C52, /* 'CCLR' V2.1+ */
icSig13colorData = 0x44434C52, /* 'DCLR' V2.1+ */
icSig14colorData = 0x45434C52, /* 'ECLR' V2.1+ */
icSig15colorData = 0x46434C52, /* 'FCLR' V2.1+ */
/* ICCLIB extension (synonyms for N-Color) */
icSigMch2Data = 0x4D434832, /* 'MCH2' Colorsync ? */
icSigMch3Data = 0x4D434833, /* 'MCH3' Colorsync ? */
icSigMch4Data = 0x4D434834, /* 'MCH4' Colorsync ? */
icSigMch5Data = 0x4D434835, /* 'MCH5' Colorsync ? */
icSigMch6Data = 0x4D434836, /* 'MCH6' Colorsync ? Hexachrome: CMYKOG */
icSigMch7Data = 0x4D434837, /* 'MCH7' Colorsync ? */
icSigMch8Data = 0x4D434838, /* 'MCH8' Colorsync ? */
icSigMch9Data = 0x4D434839, /* 'MCH9' Colorsync ? */
icSigMchAData = 0x4D434841, /* 'MCHA' Colorsync ? */
icSigMchBData = 0x4D434842, /* 'MCHB' Colorsync ? */
icSigMchCData = 0x4D434843, /* 'MCHC' Colorsync ? */
icSigMchDData = 0x4D434844, /* 'MCHD' Colorsync ? */
icSigMchEData = 0x4D434845, /* 'MCHE' Colorsync ? */
icSigMchFData = 0x4D434846, /* 'MCHF' Colorsync ? */
icMaxEnumColorSpace = icMaxTagVal
} icColorSpaceSignature;
/* profileClass enumerations */
typedef enum {
icSigInputClass = 0x73636E72, /* 'scnr' */
icSigDisplayClass = 0x6D6E7472, /* 'mntr' */
icSigOutputClass = 0x70727472, /* 'prtr' */
icSigLinkClass = 0x6C696E6B, /* 'link' */
icSigColorSpaceClass = 0x73706163, /* 'spac' */
icSigAbstractClass = 0x61627374, /* 'abst' */
icSigNamedColorClass = 0x6e6d636c, /* 'nmcl' */
icMaxEnumClass = icMaxTagVal
} icProfileClassSignature;
/* Platform Signatures */
typedef enum {
icSigNoPlatform = 0x00000000, /* Not specified (V2.2+) */
icSigMacintosh = 0x4150504C, /* 'APPL' */
icSigMicrosoft = 0x4D534654, /* 'MSFT' */
icSigSolaris = 0x53554E57, /* 'SUNW' */
icSigSGI = 0x53474920, /* 'SGI ' */
icSigTaligent = 0x54474E54, /* 'TGNT' */
icMaxEnumPlatform = icMaxTagVal
} icPlatformSignature;
/* Device Manufacturer signatures */
/* (Omitted due to difficulty in getting a machine readable list) */
typedef unsigned int icDeviceManufacturerSignature;
#define icMaxEnumDeviceManufacturer (icDeviceManufacturerSignature)icMaxTagVal)
/* Device Model signatures */
/* (Omitted due to difficulty in getting a machine readable list) */
typedef unsigned int icDeviceModelSignature;
#define icMaxEnumDeviceModel (icDeviceModelSignature)icMaxTagVal)
/* CMM signatures (from registry, March 4 2021) */
typedef enum {
icSigAdobeCMM = 0x41444245, /* 'ADBE' */
icSigAgfaCMM = 0x41434D53, /* 'ACMS' */
icSigAppleCMM = 0x6170706C, /* 'appl' */
icSigColorGearCMM = 0x43434D53, /* 'CCMS' (Canon) */
icSigColorGearLiteCMM = 0x5543434D, /* 'UCCM' (Canon) */
icSigColorGearCCMM = 0x55434D53, /* 'UCMS' (Canon) */
icSigEFICMM = 0x45464920, /* 'EFI ' */
icSigFujiFilmCMM = 0x46462020, /* 'FF ' */
icSigExactScanCMM = 0x45584143, /* 'EXAC' */
icSigHarlequinCMM = 0x48434d4d, /* 'HCMM' */
icSigArgyllCMM = 0x6172676C, /* 'argl' */
icSigLogoSyncCMM = 0x44676f53, /* 'LgoS' (GretagMacbeth) */
icSigHeidelbergCMM = 0x48444d20, /* 'HDM ' */
icSigLittleCMSCMM = 0x6C636d73, /* 'lcms' */
icSigReflccMAXCMM = 0x52494d58, /* 'RIMX' */
icSigDemoIccMAXCMM = 0x44494d58, /* 'DIMX' */
icSigKodakCMM = 0x4b434d53, /* 'KCMS' */
icSigKonicaMinoltaCMM = 0x4d434d44, /* 'MCML' */
icSigMicrosoftCMM = 0x57435320, /* 'WCS ' */
icSigMutohCMM = 0x5349474E, /* 'SIGN' */
icSigOnyxGraphicsCMM = 0x4f4e5958, /* 'ONYX' */
icSigDeviceLinkCMM = 0x52474d53, /* 'RGMS' (Rolf Gierling Multitools) */
icSigSampleICCCMM = 0x53494343, /* 'SICC' */
icSigToshibaCMM = 0x54434d4d, /* 'TCMM' */
icSigImagingFactoryCMM = 0x33324254, /* '32BT' */
icSigVivoCMM = 0x7669766f, /* 'vivo' */
icSigWareToGoCMM = 0x57544720, /* 'WTG ' */
icSigZoranCMM = 0x7a633030, /* 'zc00' */
icMaxEnumCMM = icMaxTagVal
} icCMMSignature;
/* Technology signature descriptions */
typedef enum {
icSigTechnologyUnknown = 0x00000000, /* (from profileSequenceDescType) */
icSigFilmScanner = 0x6673636E, /* 'fscn' */
icSigDigitalCamera = 0x6463616D, /* 'dcam' */
icSigReflectiveScanner = 0x7273636E, /* 'rscn' */
icSigInkJetPrinter = 0x696A6574, /* 'ijet' */
icSigThermalWaxPrinter = 0x74776178, /* 'twax' */
icSigElectrophotographicPrinter = 0x6570686F, /* 'epho' */
icSigElectrostaticPrinter = 0x65737461, /* 'esta' */
icSigDyeSublimationPrinter = 0x64737562, /* 'dsub' */
icSigPhotographicPaperPrinter = 0x7270686F, /* 'rpho' */
icSigFilmWriter = 0x6670726E, /* 'fprn' */
icSigVideoMonitor = 0x7669646D, /* 'vidm' */
icSigVideoCamera = 0x76696463, /* 'vidc' */
icSigProjectionTelevision = 0x706A7476, /* 'pjtv' */
icSigCRTDisplay = 0x43525420, /* 'CRT ' */
icSigPMDisplay = 0x504D4420, /* 'PMD ' */
icSigAMDisplay = 0x414D4420, /* 'AMD ' */
icSigPhotoCD = 0x4B504344, /* 'KPCD' */
icSigPhotoImageSetter = 0x696D6773, /* 'imgs' */
icSigGravure = 0x67726176, /* 'grav' */
icSigOffsetLithography = 0x6F666673, /* 'offs' */
icSigSilkscreen = 0x73696C6B, /* 'silk' */
icSigFlexography = 0x666C6578, /* 'flex' */
icSigMotionPictureFilmScanner = 0x6D706673, /* 'mpfs' V4.3+ */
icSigMotionPictureFilmRecorder = 0x6D706673, /* 'mpfr' V4.3+ */
icSigDigitalMotionPictureCamera = 0x646D7063, /* 'dmpc' V4.3+ */
icSigDigitalCinemaProjector = 0x64636A70, /* 'dcpj' V4.3+ */
icMaxEnumTechnology = icMaxTagVal
} icTechnologySignature;
/*------------------------------------------------------------------------*/
/*
* Other enums (Should these be "icSig..." ?)
*/
/* Measurement Geometry, used in the measurmentType tag */
typedef enum {
icGeometryUnknown = 0x00000000, /* Unknown */
icGeometry045or450 = 0x00000001, /* 0/45, 45/0 */
icGeometry0dord0 = 0x00000002, /* 0/d or d/0 */
icMaxEnumGeometry = icMaxTagVal
} icMeasurementGeometry;
/* Rendering Intents, used in the profile header */
typedef enum {
icPerceptual = 0,
icRelativeColorimetric = 1,
icSaturation = 2,
icAbsoluteColorimetric = 3,
icMaxEnumIntent = icMaxTagVal
} icRenderingIntent;
/* Different Spot Shapes currently defined, used for screeningType */
typedef enum {
icSpotShapeUnknown = 0,
icSpotShapePrinterDefault = 1,
icSpotShapeRound = 2,
icSpotShapeDiamond = 3,
icSpotShapeEllipse = 4,
icSpotShapeLine = 5,
icSpotShapeSquare = 6,
icSpotShapeCross = 7,
icMaxEnumSpot = icMaxTagVal
} icSpotShape;
/* Standard Observer, used in the measurmentType tag */
typedef enum {
icStdObsUnknown = 0x00000000, /* Unknown */
icStdObs1931TwoDegrees = 0x00000001, /* 2 deg */
icStdObs1964TenDegrees = 0x00000002, /* 10 deg */
icMaxEnumStdObs = icMaxTagVal
} icStandardObserver;
/* Pre-defined illuminants, used in measurement and viewing conditions type */
typedef enum {
icIlluminantUnknown = 0x00000000,
icIlluminantD50 = 0x00000001,
icIlluminantD65 = 0x00000002,
icIlluminantD93 = 0x00000003,
icIlluminantF2 = 0x00000004,
icIlluminantD55 = 0x00000005,
icIlluminantA = 0x00000006,
icIlluminantEquiPowerE = 0x00000007,
icIlluminantF8 = 0x00000008,
icMaxEnumIlluminant = icMaxTagVal
} icIlluminant;
/* A not so exhaustive list of language codes */
typedef enum {
icLanguageCodeEnglish = 0x656E, /* 'en' */
icLanguageCodeGerman = 0x6465, /* 'de' */
icLanguageCodeItalian = 0x6974, /* 'it' */
icLanguageCodeDutch = 0x6E6C, /* 'nl' */
icLanguageCodeSweden = 0x7376, /* 'sv' */
icLanguageCodeSpanish = 0x6573, /* 'es' */
icLanguageCodeDanish = 0x6461, /* 'da' */
icLanguageCodeNorwegian = 0x6E6F, /* 'no' */
icLanguageCodeJapanese = 0x6A61, /* 'ja' */
icLanguageCodeFinish = 0x6669, /* 'fi' */
icLanguageCodeTurkish = 0x7472, /* 'tr' */
icLanguageCodeKorean = 0x6B6F, /* 'ko' */
icLanguageCodeChinese = 0x7A68, /* 'zh' */
icLanguageCodeFrench = 0x6672, /* 'fr' */
icMaxEnumLanguageCode = icMaxTagVal
} icEnumLanguageCode;
/* A not so exhaustive list of region codes. */
typedef enum {
icRegionCodeUSA = 0x5553, /* 'US' */
icRegionCodeUnitedKingdom = 0x554B, /* 'UK' */
icRegionCodeGermany = 0x4445, /* 'DE' */
icRegionCodeItaly = 0x4954, /* 'IT' */
icRegionCodeNetherlands = 0x4E4C, /* 'NL' */
icRegionCodeSpain = 0x4543, /* 'ES' */
icRegionCodeDenmark = 0x444B, /* 'DK' */
icRegionCodeNorway = 0x4E4F, /* 'ND' */
icRegionCodeJapan = 0x4A50, /* 'JP' */
icRegionCodeFinland = 0x4649, /* 'FI' */
icRegionCodeTurkey = 0x5452, /* 'TR' */
icRegionCodeKorea = 0x4B52, /* 'KR' */
icRegionCodeChina = 0x434E, /* 'CN' */
icRegionCodeTaiwan = 0x5457, /* 'TW' */
icRegionCodeFrance = 0x4652, /* 'FR' */
icRegionCodeAustralia = 0x4155, /* 'AU' */
icMaxEnumRegionCode = icMaxTagVal
} icEnumRegionCode;
/* Microsoft platform Device Settings ID Signatures */
typedef enum {
icSigMsftResolution = 0x72736c6e, /* 'rsln' */
icSigMsftMedia = 0x6d747970, /* 'mtyp' */
icSigMsftHalftone = 0x6866746e, /* 'hftn' */
icMaxEnumDevSetMsftID = icMaxTagVal
} icDevSetMsftIDSignature;
/* Microsoft platform Media Type Encoding */
typedef enum {
icMsftMediaStandard = 1,
icMsftMediaTrans = 2, /* transparency */
icMsftMediaGloss = 3,
icMsftMediaUser1 = 256,
icMaxEnumMsftMedia = icMaxTagVal
} icDevSetMsftMedia;
/* Microsoft platform Halftone Values */
typedef enum {
icMsftDitherNone = 1,
icMsftDitherCoarse = 2,
icMsftDitherFine = 3,
icMsftDitherLineArt = 4,
icMsftDitherErrorDiffusion = 5,
icMsftDitherReserved6 = 6,
icMsftDitherReserved7 = 7,
icMsftDitherReserved8 = 8,
icMsftDitherReserved9 = 9,
icMsftDitherGrayScale = 10,
icMsftDitherUser1 = 256,
icMsftMaxEnumMsftDither = icMaxTagVal
} icDevSetMsftDither;
/* measurement units for the icResponseCurveSet16Type */
typedef enum {
icSigStatusA = 0x53746141, /* 'StaA' */
icSigStatusE = 0x53746145, /* 'StaE' */
icSigStatusI = 0x53746149, /* 'StaI' */
icSigStatusT = 0x53746154, /* 'StaT' */
icSigStatusM = 0x5374614d, /* 'StaM' */
icSigDN = 0x444e2020, /* 'DN ' */
icSigDNP = 0x444e2050, /* 'DN P' */
icSigDNN = 0x444e4e20, /* 'DNN ' */
icSigDNNP = 0x444e4e50, /* 'DNNP' */
icMaxEnumMeasUnits = icMaxTagVal
} icMeasUnitsSig;
/* Phosphor Colorant and Phosphor Encodings used in chromaticity type */
typedef enum {
icPhColUnknown = 0x0000, /* Unknown */
icPhColITU_R_BT_709 = 0x0001, /* ITU-R BT.709 */
icPhColSMPTE_RP145_1994 = 0x0002, /* SMPTE RP145-1994 */
icPhColEBU_Tech_3213_E = 0x0003, /* EBU Tech.3213-E */
icPhColP22 = 0x0004, /* P22 */
icPhColP3 = 0x0005, /* P3 */
icPhColITU_R_BT2020 = 0x0006, /* ITU-R BT.2020 */
icMaxEnumPhCol = icMaxTagVal
} icPhColEncoding;
/* Formula curve segment encoding (V4.3+) */
typedef enum {
icCurveSegFunction1 = 0x0000, /* Y = (a * X + b)^g + c */
icCurveSegFunction2 = 0x0001, /* Y = a * log10(b * X^g + c) + d */
icCurveSegFunction3 = 0x0002, /* Y = a * b^(c * X + d) + e */
icMaxEnumCurveSegFunctionType = icMaxTagVal
} icCurveSegFunctionType;
/* Parametric curve types for icSigParametricCurveType (V4.0+) */
typedef enum {
icCurveFunction1 = 0x0000, /* Y = X ^ p0 */
icCurveFunction2 = 0x0001, /* Y = X >= -p2/p1 ? Y = (p1 * X + p2)^p0 : 0 */
icCurveFunction3 = 0x0002, /* Y = X >= -p2/p1 ? Y = (p1 * X + p2)^p0 + p3 : p3 */
icCurveFunction4 = 0x0003, /* Y = X >= p4 ? Y = (p1 * X + p2)^p0 : p3 * X */
icCurveFunction5 = 0x0004, /* Y = X >= p4 ? Y = (p1 * X + p2)^p0 + p5 : p3 * X + p6 */
icMaxEnumCurveFunctionType = icMaxTagVal
} icParametricCurveFunctionType;
/* Types for icSigColorimetricIntentImageStateTag signatures (V4.3+) */
typedef enum {
icSceneColorimetryEstimates = 0x73636F65, /* 'scoe' */
icSceneAppearanceEstimates = 0x73617065, /* 'sape' */
icFocalPlaneColorimetryEstimates = 0x66706365, /* 'fpce' */
icReflectionHardcopyOriginalColorimetry = 0x72686F63, /* 'rhoc' */
icReflectionPrintOutputColorimetry = 0x72706F63, /* 'rpoc' */
icMaxEnumColorimetricIntentImageState = icMaxTagVal
} icColorimetricIntentImageStateSig;
/* Reference Medium Gamut Signatures (V4.3+) */
typedef enum {
icSigPerceptualReferenceMediumGamut = 0x70726d67, /* 'prmg' */
icMaxEnumReferenceMediumGamut = icMaxTagVal
} icReferenceMediumGamutSignature;
#ifdef __cplusplus
}
#endif
#endif /* ICCV44_H */

2756
Argyll_V3.5.0/icc/icc_pe.c Normal file

File diff suppressed because it is too large Load Diff

693
Argyll_V3.5.0/icc/icc_pe.h Normal file
View File

@@ -0,0 +1,693 @@
/*
* International Color Consortium Format Library (icclib)
*
* Author: Graeme W. Gill
* Date: 2022/12/15
* Version: 3.0.0
*
* Copyright 1997 - 2023 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/* icmPe transform declarations */
/* This is #included in icc.h */
/* Sig (etype) of processing elements */
/* (Update icmPeSig2str() too) */
typedef enum {
icmSigPeNone = icmMakeTag(0,0,0,0), /* Not an icmPe */
icmSigPeCurveSet = icmMakeTag('P','e','c','s'), /* A set of N x 1d Curves */
icmSigPeCurve = icmMakeTag('P','e','c','u'), /* A linear/gamma/table curve */
icmSigPeMatrix = icmMakeTag('P','e','m','a'), /* An N x M + F matrix */
icmSigPeClut = icmMakeTag('P','e','c','l'), /* An N x M cLUT */
icmSigPeLut816 = icmMakeTag('P','e','l','8'),
icmSigPeContainer = icmMakeTag('P','e','c','r'), /* A sequence of other icmPe's */
icmSigPeInverter = icmMakeTag('P','e','i','v'), /* An inverter */
icmSigPeMono = icmMakeTag('P','e','m','o'), /* Mono conversion part of ShaperMono */
icmSigPeShaperMatrix = icmMakeTag('P','e','s','m'), /* A shaper/matrix sequence */
icmSigPeShaperMono = icmMakeTag('P','e','s','o'), /* A shaper/mono sequence */
/* Format conversions */
icmSigPeXYZ2Lab = icmMakeTag('P','e','x','l'),
icmSigPeAbs2Rel = icmMakeTag('P','e','a','r'),
icmSigPeXYZ2XYZ8 = icmMakeTag('P','e','x','1'),
icmSigPeXYZ2XYZ16 = icmMakeTag('P','e','x','2'),
icmSigPeLab2Lab8 = icmMakeTag('P','e','l','1'),
icmSigPeLab2LabV2 = icmMakeTag('P','e','l','2'),
icmSigPeGeneric2Norm = icmMakeTag('P','e','G','e'), /* Generic normalization */
icmSigPeGridAlign = icmMakeTag('P','e','G','a'), /* Grid align */
icmSigPeNOP = icmMakeTag('P','e','N','O'), /* A NOP */
icmPeMaxEnum = icMaxTagVal
} icmPeSignature;
/* See icmPeSig2str() for text */
/* Lookup return values */
typedef enum {
icmPe_lurv_OK = 0x00, /* Lookup is OK */
icmPe_lurv_clip = 0x01, /* Clipping warning */
icmPe_lurv_bwclp = 0x02, /* lookup_bwd on clipping PeCurveFmlaSeg */
icmPe_lurv_num = 0x04, /* Numerical limit reached warning */
icmPe_lurv_imp = 0x08, /* Not implemented error */
icmPe_lurv_cfg = 0x10, /* Configuration error */
icmPe_lurv_err = 0x18 /* Error mask */
} icmPe_lurv;
char *icmPe_lurv2str(icmPe_lurv err);
/* PE operation classification */
typedef enum { /* Dominant operation type */
icmPeOp_NOP = 0x0, /* No operation */
icmPeOp_perch = 0x1, /* A per-channel operation */
icmPeOp_matrix = 0x2, /* A matrix interchannel operation (maybe abs<->rel or Mono) */
icmPeOp_cLUT = 0x3, /* A cLUT interchannel operation */
icmPeOp_fmt = 0x4, /* PCS format transform (i.e. XYZ <->Lab) */
icmPeOp_complex = 0x5 /* A complex set of interchannel operations */
} icmPeOp;
char *icmPe_Op2str(icmPeOp op);
/* icmPe attributes. */
typedef struct {
char comp; /* nz if Compound element contains other Pe's (for trace) */
char inv; /* nz if element was created with inverted function (for trace) */
char norm; /* nz if normalization type operation */
icmPeOp op; /* Operation type */
char fwd; /* nz if fwd transform is implemented */
char bwd; /* nz if bwd transform is implemented */
} icmPeAttr;
char *icmPe_Attr2Str(icmPeAttr *attr);
#define ICM_PE_SETATTR(ATTR, COMP, INV, NORM, OP, FWD, BWD) \
ATTR.comp = COMP; \
ATTR.inv = INV; \
ATTR.norm = NORM; \
ATTR.op = OP; \
ATTR.fwd = FWD; \
ATTR.bwd = BWD; \
/* Processing Element base class definition */
/* This inherets from icmBase */
#define ICM_PE_MEMBERS(ECLASS) \
ICM_BASE_MEMBERS(ECLASS) \
unsigned int inputChan; /* No. of input channels */ \
unsigned int outputChan; /* No. of output channels */ \
icmPeAttr attr; /* attributes of transforms */ \
int isPeSeq; /* nz if is superclass of icmPeSeq */ \
\
int trace; /* Trace level, 1 = top, > 1 = recursion level */ \
\
/* Init anything that depends on the processing (i.e. attr, inverse comp etc.) */ \
/* Return nz on error */ \
int (*init) (ECLASS *p); \
\
/* Translate a value through the Pe, return any warning flags */ \
/* (Where are warning flags defined ? Clip ?, F.P. error ?) */ \
icmPe_lurv (*lookup_fwd) (ECLASS *p, double *out, double *in); /* Forwards */ \
icmPe_lurv (*lookup_bwd) (ECLASS *p, double *out, double *in); /* Backwards */ \
/* Processing Element Initialisation */
#define ICM_PE_INIT(ECLASS, ESIG) \
p->etype = ESIG; \
p->init = (int (*)(ECLASS *))icmPeDummy_init; \
/* Processing Element allocation and initialisation */
/* Returns NULL on error */
#define ICM_PE_ALLOCINIT(ECLASS, ESIG, TSIG) \
ICM_BASE_ALLOCINIT(ECLASS, TSIG) \
ICM_PE_INIT(ECLASS, ESIG) \
/* Non-serialisable init */
#define ICM_PE_NS_ALLOCINIT(ECLASS, ESIG) \
ICM_BASE_NS_ALLOCINIT(ECLASS) \
ICM_PE_INIT(ECLASS, ESIG) \
/* A Processing Element */
struct _icmPe {
ICM_PE_MEMBERS(struct _icmPe)
}; typedef struct _icmPe icmPe;
/* Structure for managing Pe's */
struct _icmPePrivStr {
int dup; /* Duplicate Pe flag */
icmPositionNumber pn; /* Offset and size of sub-tag */
}; typedef struct _icmPePrivStr icmPePrivStr;
/* ----------------------- */
/* A sequence of icmPe's */
/* Processing Element Sequence base class definition */
/* This inherets from icmPe */
#define ICM_PE_SEQ_MEMBERS(ECLASS) \
ICM_PE_MEMBERS(ECLASS) \
\
/* Private: */ \
unsigned int _count; /* Count currently allocated */ \
unsigned int nncount; /* Count of non-NULL pe's */ \
\
/* Public: */ \
unsigned int count; /* Count of processing elements */ \
icmPe **pe; /* Array of [count] processing elements */ \
/* Processing Element Sequenece allocation and initialisation. */
/* (It's assumed that the parent class provides all methods) */
/* Returns NULL on error */
#define ICM_PE_SEQ_ALLOCINIT(ECLASS, ESIG, TSIG) \
ICM_PE_ALLOCINIT(ECLASS, ESIG, TSIG) \
p->isPeSeq = 1; \
p->init = (int (*)(ECLASS *))icmPeSeq_init; \
p->lookup_fwd = (icmPe_lurv (*)(ECLASS *, double *, double *))icmPeSeq_lookup_fwd; \
p->lookup_bwd = (icmPe_lurv (*)(ECLASS *, double *, double *))icmPeSeq_lookup_bwd; \
/* Non-serialisable init */
#define ICM_PE_SEQ_NS_ALLOCINIT(ECLASS, ESIG) \
ICM_PE_NS_ALLOCINIT(ECLASS, ESIG) \
p->isPeSeq = 1; \
p->init = (int (*)(ECLASS *))icmPeSeq_init; \
p->lookup_fwd = (icmPe_lurv (*)(ECLASS *, double *, double *))icmPeSeq_lookup_fwd; \
p->lookup_bwd = (icmPe_lurv (*)(ECLASS *, double *, double *))icmPeSeq_lookup_bwd; \
/* A Processing Element Sequence */
struct _icmPeSeq {
ICM_PE_SEQ_MEMBERS(struct _icmPeSeq)
}; typedef struct _icmPeSeq icmPeSeq;
/* ================================================================================== */
/* ----------------------- */
/* A set of N x 1d Curves */
/* etype icmSigPeCurveSet */
/* ttype icmSig816Curves */
struct _icmPeCurveSet {
ICM_PE_MEMBERS(struct _icmPeCurveSet)
/* Private: */
icmPePrivStr pei[MAX_CHAN]; /* Management info. */
unsigned int bpv; /* Bytes per value (Lut1 only) */
/* Public: */
icmPe *pe[MAX_CHAN]; /* 1D curves */
}; typedef struct _icmPeCurveSet icmPeCurveSet;
/* A fake internal Sig 'l1vs' for icmLut8 and icmLut16 curves */
#define icmSig816Curves ((icTagTypeSignature)icmMakeTag('l','1','v','s'))
/* ----------------------- */
/* A linear/gamma/table (sample) curve */
/* etype icmSigPeCurve */
/* ttype icSigCurveType */
/* ttype icmSig816Curve */
/* icmPeCurve reverse lookup information */
typedef struct {
int inited; /* Flag */
double rmin, rmax; /* Range of reverse grid */
double qscale; /* Quantising scale factor */
int rsize; /* Number of reverse lists */
unsigned int **rlists; /* Array of list of fwd values that may contain output value */
/* Offset 0 = allocated size */
/* Offset 1 = next free index */
/* Offset 2 = first fwd index */
unsigned int count; /* Copy of forward table size */
double *data; /* Copy of forward table data */
} icmRevTable;
typedef enum {
icmCurveUndef = -1, /* Undefined curve */
icmCurveLin = 0, /* Linear transfer curve */
icmCurveGamma = 1, /* Gamma power transfer curve */
icmCurveSpec = 2 /* Specified curve */
} icmCurveType;
struct _icmPeCurve {
ICM_PE_MEMBERS(struct _icmPeCurve)
/* Private: */
int inited; /* Flag */
unsigned int _count; /* Size currently allocated */
unsigned int bpv; /* Bytes per value (Lut1 only) */
icmRevTable rt; /* Reverse table information */
/* Public: */
icmCurveType ctype; /* Type of curve */
unsigned int count; /* Allocated and used size of the array */
double *data; /* Curve data scaled to range 0.0 - 1.0 */
/* or data[0] = gamma value */
/* or count == 0 for linear. */
}; typedef struct _icmPeCurve icmPeCurve;
typedef icmPeCurve icmCurve;
/* A fake internal Sig 'l1cv' for a icmLut8 and icmLut16 curve */
#define icmSig816Curve ((icTagTypeSignature)icmMakeTag('l','1','c','v'))
/* ----------------------- */
/* An N x M + F matrix */
/* etype icmSigPeMatrix */
/* ttype icmSig816Matrix */
struct _icmPeMatrix {
ICM_PE_MEMBERS(struct _icmPeMatrix)
/* Private: */
int inited; /* flag - if initiliase (imx, flags) */
int ivalid; /* flag - if imx is valid */
int mx_unity; /* flag - if mx[] is unity */
int ct_zero; /* flag - if ct[] is zero */
double imx[MAX_CHAN][MAX_CHAN]; /* [inn][outn] Inverse matrix values */
/* Public: */
double mx[MAX_CHAN][MAX_CHAN]; /* [outn][inn] Matrix values */
double ct[MAX_CHAN]; /* [outn] Constant values added after mx[][] multiply */
}; typedef struct _icmPeMatrix icmPeMatrix;
/* A fake internal Sig 'l1mx' for icmLut8 and icmLut16 Matrix */
#define icmSig816Matrix ((icTagTypeSignature)icmMakeTag('l','1','m','x'))
/* ----------------------- */
/* An N x M cLUT */
/* etype icmSigPeClut */
/* ttype icmSig816CLUT */
struct _icmLu4Base;
struct _icmLu4Space;
struct _icmPeClut {
ICM_PE_MEMBERS(struct _icmPeClut)
/* Private: */
unsigned int _clutsize; /* Current clut size in doubles */
int inited; /* flag - if initialised (dinc[]) */
unsigned int dinc[MAX_CHAN]; /* [inn] grid resolution values */
int dcube[1 << MAX_CHAN]; /* Hyper cube offsets (in doubles) */
int use_sx; /* flag - use simplex interpolation */
/* Public: */
unsigned int bpv; /* Bytes per value */
unsigned int clutPoints[MAX_CHAN]; /* [inn] grid resolution values */
/* (Must be all the same for icmLut) */
double *clutTable; /* clut values organized as: */
/* [inputChan 0: 0..clutPoints[0]-1].. */
/* [inputChan inn-1: 0..clutPoints[inn-1]-1] */
/* [outputChan: 0..outn-1] */
/* return the minimum and maximum values of the given channel in the clut */
void (*min_max) (struct _icmPeClut *p, double *minv, double *maxv, int chan);
/* Determine appropriate clut lookup algorithm */
void (*choose_alg) (struct _icmPeClut *p, struct _icmLu4Space *lu);
/* Return total ink limit and channel maximums. */
double (*get_tac) (
struct _icmPeClut *p,
double *chmax, /* device return channel sums. May be NULL */
icmPe *tail, /* lu tail transform from clut to device output */
void (*calfunc)(void *cntx, double *out, double *in), /* Optional calibration func. */
void *cntx
);
/* ~8 missing API's:
tune_value() cLut single value fine tune)
*/
}; typedef struct _icmPeClut icmPeClut;
/* A fake internal Sig 'l1L1' for icmLut8 and icmLut16 */
#define icmSig816CLUT ((icTagTypeSignature)icmMakeTag('l','1','L','U'))
/* ----------------------- */
/* Create an empty icmPe object. Return null on error */
/* Set ttype to the serialisation type of this Pe or its */
/* parent ttype if it doesn't use a sig in its serialisation. */
/* Use ttype = icmSigUnknownType if not a serialisable object. */
static icmPe *new_icmPe(struct _icc *icp, icTagTypeSignature ttype, icmPeSignature pesig);
/* =========================================================================== */
/* Client code populates data[i].pe etc using icc->new_pe(). */
/* ------------------------------------------------------------ */
/* Lut8Type and Lut16Type */
/* etype icmSigPeLut816 */
/* ttype icSigLut8Type */
/* ttype icSigLut16Type */
/* Indexes into underlying Pe's */
typedef enum {
icmLut816_ix_Matrix = 0,
icmLut816_ix_in = 1,
icmLut816_ix_CLUT = 2,
icmLut816_ix_out = 3
} icmLut1_ix;
struct _icmLut1 {
ICM_PE_SEQ_MEMBERS(struct _icmLut1)
/* Private: */
unsigned int bpv; /* Bytes per value for curves and cLUT */
/* Public: */
/* unsigned int inputChan; No. of input channels (in icpPeSeq) */
/* unsigned int outputChan; No. of output channels (in icpPeSeq) */
unsigned int inputEnt; /* Num of in-table entries (must be 256 for Lut8) */
unsigned int clutPoints; /* Num of grid points */
unsigned int outputEnt; /* Num of out-table entries (must be 256 for Lut8) */
/* Processing Element aliases: */
icmPeMatrix *pe_mx;
icmPeCurve **pe_ic;
icmPeClut *pe_cl;
icmPeCurve **pe_oc;
}; typedef struct _icmLut1 icmLut1;
typedef struct _icmLut1 icmLut8;
typedef struct _icmLut1 icmLut16;
/* ------------------------------------------------------------ */
/* A Pe that encodes an RGB shaper-matrix transform. */
/* This transform is always XYZ PCS. */
/* (This is not a serialisable tagtype) */
struct _icmShaperMatrix {
ICM_PE_SEQ_MEMBERS(struct _icmShaperMatrix)
/* icSigCurveType */
icmBase *redCurve, *greenCurve, *blueCurve;
icmXYZArray *redColrnt, *greenColrnt, *blueColrnt;
}; typedef struct _icmShaperMatrix icmShaperMatrix;
/* Create an empty object. Return null on error. */
/* Doesn't set icc error if tags not present. */
static icmPeSeq *new_icmShaperMatrix(
struct _icc *icp,
int invert /* If nz, setup inverse of shape-matrix */
);
/* ------------------------------------------------------------ */
/* A Pe that encodes an Monochrome shaper-mono transform. */
/* (This is not a serialisable tagtype) */
struct _icmShaperMono {
ICM_PE_SEQ_MEMBERS(struct _icmShaperMono)
/* icSigCurveType */
icmBase *grayCurve;
}; typedef struct _icmShaperMono icmShaperMono;
/* Create an empty object. Return null on error. */
/* Doesn't set icc error if tags not present. */
static icmPeSeq *new_icmShaperMono(
struct _icc *icp,
int invert /* If nz, setup inverse of shape-mono */
);
/* ------------------------------------------------------------ */
/* A Pe that implements the mono<->PCS conversion. */
/* (This is not a serialisable tagtype) */
struct _icmPeMono {
ICM_PE_MEMBERS(struct _icmPeMono)
}; typedef struct _icmPeMono icmPeMono;
/* Create the Pe */
static icmPe *new_icmPeMono(
struct _icc *icp
);
/* =========================================================== */
/* A Pe that inverts another Pe. */
/* (This is not a serialisable tagtype) */
struct _icmPeInverter {
ICM_PE_MEMBERS(struct _icmPeInverter)
icmPe *pe; /* Pe that's being inverted */
}; typedef struct _icmPeInverter icmPeInverter;
/* Make Pe appear to be its inverse. */
static icmPe *new_icmPeInverter(
struct _icc *icp,
icmPe *pe
);
/* ------------------------------------------------------------ */
/* XYZ <-> Lab Pe (This is not a serialisable tagtype) */
struct _icmPeXYZ2Lab {
ICM_PE_MEMBERS(struct _icmPeXYZ2Lab)
struct _icmLu4Space *lu;
}; typedef struct _icmPeXYZ2Lab icmPeXYZ2Lab;
static icmPe *new_icmPeXYZ2Lab(
struct _icc *icp,
struct _icmLu4Space *lu, /* pcswht */
int invert /* Lab->XYZ */
);
/* ------------------------------------------------------------ */
/* XYZ abs <-> XYZ rel Pe (This is not a serialisable tagtype) */
struct _icmPeAbs2Rel {
ICM_PE_MEMBERS(struct _icmPeAbs2Rel)
struct _icmLu4Space *lu;
}; typedef struct _icmPeAbs2Rel icmPeAbs2Rel;
static icmPe *new_icmPeAbs2Rel(
struct _icc *icp,
struct _icmLu4Space *lu, /* wp, toAbs, fromAbs */
int invert /* Lab->XYZ */
);
/* ------------------------------------------------------------ */
/* XYZ <-> XYZ8 Pe (This is not a serialisable tagtype) */
struct _icmPeXYZ2XYZ8 {
ICM_PE_MEMBERS(struct _icmPeXYZ2XYZ8)
}; typedef struct _icmPeXYZ2XYZ8 icmPeXYZ2XYZ8;
static icmPe *new_icmPeXYZ2XYZ8(
struct _icc *icp,
int invert
);
/* ------------------------------------------------------------ */
/* XYZ <-> XYZ16 Pe (This is not a serialisable tagtype) */
struct _icmPeXYZ2XYZ16 {
ICM_PE_MEMBERS(struct _icmPeXYZ2XYZ16)
}; typedef struct _icmPeXYZ2XYZ16 icmPeXYZ2XYZ16;
static icmPe *new_icmPeXYZ2XYZ16(
struct _icc *icp,
int invert
);
/* ------------------------------------------------------------ */
/* Lab <-> Lab8 Pe (This is not a serialisable tagtype) */
struct _icmPeLab2Lab8 {
ICM_PE_MEMBERS(struct _icmPeLab2Lab8)
}; typedef struct _icmPeLab2Lab8 icmPeLab2Lab8;
static icmPe *new_icmPeLab2Lab8(
struct _icc *icp,
int invert
);
/* ------------------------------------------------------------ */
/* Lab <-> LabV2 Pe (This is not a serialisable tagtype) */
struct _icmPeLab2LabV2 {
ICM_PE_MEMBERS(struct _icmPeLab2LabV2)
}; typedef struct _icmPeLab2LabV2 icmPeLab2LabV2;
static icmPe *new_icmPeLab2LabV2(
struct _icc *icp,
int invert
);
/* ------------------------------------------------------------ */
/* Generic <-> Normalized Pe (This is not a serialisable tagtype) */
/* min/max difference is sanity limited to be at least 1e-4. */
/* NOTE that these conversions don't clip. */
struct _icmPeGeneric2Norm {
ICM_PE_MEMBERS(struct _icmPeGeneric2Norm)
double min[MAX_CHAN]; /* Full range min & max */
double max[MAX_CHAN];
double nmin[MAX_CHAN]; /* Normalize range min & max */
double nmax[MAX_CHAN];
char ident[50];
}; typedef struct _icmPeGeneric2Norm icmPeGeneric2Norm;
static icmPe *new_icmPeFullyGeneric2Norm(
struct _icc *icp,
unsigned int nchan,
double *min, double *max, /* Per channel range to be normalised */
double *nmin, double *nmax, /* Per channel range to normalize to (NULL = 0..1) */
char *ident, /* Encoding identifier */
int invert
);
static icmPe *new_icmPeGeneric2Norm(
struct _icc *icp,
unsigned int nchan,
double *min, double *max, /* Per channel range to be normalised */
char *ident, /* Encoding identifier */
int invert
);
/* ------------------------------------------------------------ */
/* A point to grid alignment transform. */
/* This creates a per channel transform that piecwize bends */
/* the input so as to land the given point on a grid point. */
/* The values are assumed in the range 0..1 */
struct _icmPeGridAlign {
ICM_PE_MEMBERS(struct _icmPeGridAlign)
double src[MAX_CHAN];
double dst[MAX_CHAN];
double fwdlow[MAX_CHAN];
double fwdhigh[MAX_CHAN];
double bwdlow[MAX_CHAN];
double bwdlowoff[MAX_CHAN];
double bwdhigh[MAX_CHAN];
double bwdhighoff[MAX_CHAN];
}; typedef struct _icmPeGridAlign icmPeGridAlign;
static icmPe *new_icmPeGridAlign(
struct _icc *icp,
unsigned int nchan,
double *point, /* Point to aim for, must be 0..1 */
unsigned int *clutPoints, /* Grid resolution for each channel */
int invert
);
/* ------------------------------------------------------------ */
/* A NOP (This is not a serialisable tagtype) */
struct _icmPeNOP {
ICM_PE_MEMBERS(struct _icmPeNOP)
}; typedef struct _icmPeNOP icmPeNOP;
static icmPe *new_icmPeNOP(
struct _icc *icp,
unsigned int nchan
);
/* ========================================================= */
/* A Processing Element Container (This is not a serialisable tagtype) */
struct _icmPeContainer {
ICM_PE_SEQ_MEMBERS(struct _icmPeContainer)
/* Added Pe's will have their reference counts incremented, */
/* so if we adding a new_PeXXX, we need to delete it after adding. */
/* Removed Pe's will have their reference counts decremented. */
/* All these will return an error code. */
/* Add a Pe to the end of the sequence */
int (*append) (struct _icmPeContainer *p, icmPe *pe);
/* Add a Pe to the start of the sequence */
int (*prepend) (struct _icmPeContainer *p, icmPe *pe);
/* Insert a Pe before the given index */
int (*insert) (struct _icmPeContainer *p, unsigned int ix, icmPe *pe);
/* Replace the Pe at the given index */
int (*replace) (struct _icmPeContainer *p, unsigned int ix, icmPe *pe);
/* Remove the Pe at the given index */
int (*remove) (struct _icmPeContainer *p, unsigned int ix);
/* Append Pe's from another icmPeContainer, */
/* starting at six and ending before eix. */
/* Any empty or attr == NOP are skipped. */
/* This will flatten any sub-icmPeSeq, resulting in a sequence */
/* of direct Pe's or direct Pe's inside an Inverter. */
int (*append_pes) (struct _icmPeContainer *p, struct _icmPeSeq *src, int six, int eix);
/* Various icmPeContainer/icmPeSeq characteristic analysis methods: */
/* These all assume that the icmPeContainer is in a flattened state. */
/* Find the largest per channel input lut resolution. */
/* res may be NULL */
/* Returns 0 if there is no per channel lut in the input sequence. */
unsigned int (*max_in_res)(struct _icmPeContainer *p, int res[MAX_CHAN]);
/* Find the largest cLUT clutPoints[] value. */
/* res may be NULL */
/* Returns 0 if there is no cLut transform in the sequence. */
unsigned int (*max_clut_res)(struct _icmPeContainer *p, int res[MAX_CHAN]);
/* Find the largest per channel output lut resolution. */
/* res may be NULL */
/* Returns 0 if there is no per channel lut in the output sequence. */
unsigned int (*max_out_res)(struct _icmPeContainer *p, int res[MAX_CHAN]);
/* Determine if the per channel input or output is likely to be */
/* in a linear light space. We do this by seeing if the first */
/* non-per channel or format element is a matrix or matrix like element. */
int (*linear_light_inout)(struct _icmPeContainer *p, int dir);
/* Return a pointer to the last icmPeLut and a Seq containing */
/* the transforms from the output of the Lut */
/* Return NULL if no icmPeLut */
/* Delete both objects when done */
icmPeClut *(*get_lut)(
struct _icmPeContainer *p,
struct _icmPeContainer **ptail /* If not NULL return tail process, NULL if none */
);
/* Return total ink limit and channel maximums. */
/* return -1.0 if this lu doesn't have an icmPeClut in it */
double (*get_tac) (
struct _icmPeContainer *p,
double *chmax, /* device return channel maximums. May be NULL */
void (*calfunc)(void *cntx, double *out, double *in), /* Optional calibration func. */
void *cntx
);
}; typedef struct _icmPeContainer icmPeContainer;
/* Create an empty object. Return null on error */
static icmPeContainer *new_icmPeContainer(
struct _icc *icp,
int dinch, /* Default number of input channels, 0 OK if will add non-NULL memb. Pe. */
int doutch /* Default number of output channels, 0 OK if will add non-NULL memb. Pe. */
);

4666
Argyll_V3.5.0/icc/icc_util.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,859 @@
#ifndef ICC_UTIL_H
#define ICC_UTIL_H
/*
* International Color Consortium Format Library (icclib)
* Utility functions used by icclib and other code.
*
* Author: Graeme W. Gill
* Date: 1999/11/29
* Version: 3.0.0
*
* Copyright 1997 - 2022 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/*
* The distinction between "core" and "utility" functions is somewhat
* arbitrary.
*/
/* We can get some subtle errors if certain headers aren't included */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Set a 3 vector to the same value */
#define icmSet3(d_ary, s_val) ((d_ary)[0] = (s_val), (d_ary)[1] = (s_val), \
(d_ary)[2] = (s_val))
/* Set a 3 vector to 3 values */
#define icmInit3(d_ary, s1, s2, s3) ((d_ary)[0] = (s1), (d_ary)[1] = (s2), \
(d_ary)[2] = (s3))
/* Some 2 vector macros: */
#define icmSet2(d_ary, s_val) ((d_ary)[0] = (s_val), (d_ary)[1] = (s_val))
#define icmCpy2(d_ary, s_ary) ((d_ary)[0] = (s_ary)[0], (d_ary)[1] = (s_ary)[1])
#define icmAdd2(d_ary, s1_ary, s2_ary) ((d_ary)[0] = (s1_ary)[0] + (s2_ary)[0], \
(d_ary)[1] = (s1_ary)[1] + (s2_ary)[1])
#define icmSub2(d_ary, s1_ary, s2_ary) ((d_ary)[0] = (s1_ary)[0] - (s2_ary)[0], \
(d_ary)[1] = (s1_ary)[1] - (s2_ary)[1])
/* Copy a 3 vector */
#define icmCpy3(d_ary, s_ary) ((d_ary)[0] = (s_ary)[0], (d_ary)[1] = (s_ary)[1], \
(d_ary)[2] = (s_ary)[2])
/* Copy a 4 vector */
#define icmCpy4(d_ary, s_ary) ((d_ary)[0] = (s_ary)[0], (d_ary)[1] = (s_ary)[1], \
(d_ary)[2] = (s_ary)[2], (d_ary)[3] = (s_ary)[3])
/* - - - - - - - - - - - - - - */
/* Clamp a 3 vector to be +ve */
void icmClamp3(double out[3], double in[3]);
/* Invert (negate) a 3 vector */
void icmInv3(double out[3], double in[3]);
/* Add two 3 vectors */
void icmAdd3(double out[3], double in1[3], double in2[3]);
#define ICMADD3(o, i, j) ((o)[0] = (i)[0] + (j)[0], (o)[1] = (i)[1] + (j)[1], (o)[2] = (i)[2] + (j)[2])
/* Subtract two 3 vectors, out = in1 - in2 */
void icmSub3(double out[3], double in1[3], double in2[3]);
#define ICMSUB3(o, i, j) ((o)[0] = (i)[0] - (j)[0], (o)[1] = (i)[1] - (j)[1], (o)[2] = (i)[2] - (j)[2])
/* Divide two 3 vectors, out = in1/in2 */
void icmDiv3(double out[3], double in1[3], double in2[3]);
#define ICMDIV3(o, i, j) ((o)[0] = (i)[0]/(j)[0], (o)[1] = (i)[1]/(j)[1], (o)[2] = (i)[2]/(j)[2])
/* Multiply two 3 vectors, out = in1 * in2 */
void icmMul3(double out[3], double in1[3], double in2[3]);
#define ICMMUL3(o, i, j) ((o)[0] = (i)[0] * (j)[0], (o)[1] = (i)[1] * (j)[1], (o)[2] = (i)[2] * (j)[2])
/* Take (signed) values to power */
void icmPow3(double out[3], double in[3], double p);
/* Square values */
void icmSqr3(double out[3], double in[3]);
/* Square root of values */
void icmSqrt3(double out[3], double in[3]);
/* Take absolute of a 3 vector */
void icmAbs3(double out[3], double in[3]);
/* Compute sum of the vectors components */
#define icmSum3(vv) ((vv)[0] + (vv)[1] + (vv)[2])
/* Compute the dot product of two 3 vectors */
double icmDot3(double in1[3], double in2[3]);
#define ICMDOT3(o, i, j) ((o) = (i)[0] * (j)[0] + (i)[1] * (j)[1] + (i)[2] * (j)[2])
/* Compute the cross product of two 3D vectors, out = in1 x in2 */
void icmCross3(double out[3], double in1[3], double in2[3]);
/* Compute the norm squared (length squared) of a 3 vector */
double icmNorm3sq(double in[3]);
#define ICMNORM3SQ(i) ((i)[0] * (i)[0] + (i)[1] * (i)[1] + (i)[2] * (i)[2])
/* Compute the norm (length) of a 3 vector */
double icmNorm3(double in[3]);
#define ICMNORM3(i) sqrt((i)[0] * (i)[0] + (i)[1] * (i)[1] + (i)[2] * (i)[2])
/* Scale a 3 vector by the given ratio */
void icmScale3(double out[3], double in[3], double rat);
#define ICMSCALE3(o, i, j) ((o)[0] = (i)[0] * (j), (o)[1] = (i)[1] * (j), (o)[2] = (i)[2] * (j))
/* Scale a 3 vector by the given ratio and add it */
/* i.e. out = in2 + in1 * rat */
void icmScaleAdd3(double out[3], double in2[3], double in1[3], double rat);
/* Compute a blend between in0 and in1 for bl 0..1 */
void icmBlend3(double out[3], double in0[3], double in1[3], double bf);
/* Clip a vector to the range 0.0 .. 1.0 */
void icmClip3(double out[3], double in[3]);
/* Clip a vector to the range 0.0 .. 1.0 */
/* and return nz if clipping occured */
int icmClip3sig(double out[3], double in[3]);
/* Clip a vector to the range 0.0 .. 1.0 */
/* and return any clipping margine over the limits. */
double icmClip3marg(double out[3], double in[3]);
/* Normalise a 3 vector to the given length. Return nz if not normalisable */
int icmNormalize3(double out[3], double in[3], double len);
/* Compute the norm squared (length squared) of a vector defined by two points */
double icmNorm33sq(double in1[3], double in0[3]);
/* Compute the norm (length) of of a vector defined by two points */
double icmNorm33(double in1[3], double in0[3]);
/* Scale a vector from 0->1 by the given ratio. in0[] is the origin. */
void icmScale33(double out[3], double in1[3], double in0[3], double rat);
/* Normalise a vector from 0->1 to the given length. */
/* The new location of in1[] is returned in out[], in0[] is the origin. */
/* Return nz if not normalisable */
int icmNormalize33(double out[3], double in1[3], double in0[3], double len);
/* Dump a 3x3 matrix to a stream */
void icmDump3x3(FILE *fp, char *id, char *pfx, double a[3][3]);
/* Set a 3x3 matrix to a value */
void icmSetVal3x3(double mat[3][3], double val);
/* Set a 3x3 matrix to unity */
void icmSetUnity3x3(double mat[3][3]);
/* Copy a 3x3 transform matrix */
void icmCpy3x3(double out[3][3], double mat[3][3]);
/* Add a 3x3 transform matrix to another */
void icmAdd3x3(double dst[3][3], double src1[3][3], double src2[3][3]);
/* Scale each element of a 3x3 transform matrix */
void icmScale3x3(double dst[3][3], double src[3][3], double scale);
/* Multiply 3 vector by 3x3 transform matrix */
/* Organization is mat[out][in] */
void icmMulBy3x3(double out[3], double mat[3][3], double in[3]);
/* Tensor product. Multiply two 3 vectors to form a 3x3 matrix */
/* src1[] forms the colums, and src2[] forms the rows in the result */
void icmTensMul3(double dst[3][3], double src1[3], double src2[3]);
/* Multiply one 3x3 with another */
/* dst = src * dst */
void icmMul3x3(double dst[3][3], double src[3][3]);
/* Multiply one 3x3 with another #2 */
/* dst = src1 * src2 */
void icmMul3x3_2(double dst[3][3], double src1[3][3], double src2[3][3]);
/* Compute the determinant of a 3x3 matrix */
double icmDet3x3(double in[3][3]);
/* Invert a 3x3 transform matrix. Return 1 if error. */
int icmInverse3x3(double out[3][3], double in[3][3]);
/* Transpose a 3x3 matrix */
void icmTranspose3x3(double out[3][3], double in[3][3]);
/* Given two 3D points, create a matrix that rotates */
/* and scales one onto the other about the origin 0,0,0. */
/* Use icmMulBy3x3() to apply this to other points */
void icmRotMat(double mat[3][3], double src[3], double targ[3]);
/* Copy a 3x4 transform matrix */
void icmCpy3x4(double out[3][4], double mat[3][4]);
/* Multiply 3 array by 3x4 transform matrix */
void icmMul3By3x4(double out[3], double mat[3][4], double in[3]);
/* Given two 3D vectors, create a matrix that translates, */
/* rotates and scales one onto the other. */
/* Use icmMul3By3x4 to apply this to other points */
void icmVecRotMat(double m[3][4], double s1[3], double s0[3], double t1[3], double t0[3]);
/* Compute the intersection of a vector and a plane */
/* return nz if there is no intersection */
int icmVecPlaneIsect(double isect[3], double pl_const, double pl_norm[3], double ve_1[3], double ve_0[3]);
/* Compute the closest point on a line to a point. */
/* Return closest points and parameter values if not NULL. */
int icmLinePointClosest(double ca[3], double *pa,
double la0[3], double la1[3], double pp[3]);
/* Compute the closest points between two lines a and b. */
/* Return closest points and parameter values if not NULL. */
/* Return nz if they are parallel. */
int icmLineLineClosest(double ca[3], double cb[3], double *pa, double *pb,
double la0[3], double la1[3], double lb0[3], double lb1[3]);
/* Given 3 3D points, compute a plane equation. */
/* The normal will be right handed given the order of the points */
/* The plane equation will be the 3 normal components and the constant. */
/* Return nz if any points are cooincident or co-linear */
int icmPlaneEqn3(double eq[4], double p0[3], double p1[3], double p2[3]);
/* Given a 3D point and a plane equation, return the signed */
/* distance from the plane */
double icmPlaneDist3(double eq[4], double p[3]);
/* - - - - - - - - - - - - - - - - - - - - - - - */
/* Multiply 4 vector by 4x4 transform matrix */
/* Organization is mat[out][in] */
void icmMulBy4x4(double out[4], double mat[4][4], double in[4]);
/* Transpose a 4x4 matrix */
void icmTranspose4x4(double out[4][4], double in[4][4]);
/* Clip a vector to the range 0.0 .. 1.0 */
/* and return any clipping margine over the limit */
double icmClip4marg(double out[4], double in[4]);
/* - - - - - - - - - - - - - - - - - - - - - - - */
#define icmNorm2(i) sqrt((i)[0] * (i)[0] + (i)[1] * (i)[1])
#define icmNorm2sq(i) ((i)[0] * (i)[0] + (i)[1] * (i)[1])
/* Compute the norm (length) of of a vector defined by two points */
double icmNorm22(double in1[2], double in0[2]);
/* Compute the norm (length) squared of of a vector defined by two points */
double icmNorm22sq(double in1[2], double in0[2]);
/* Compute the dot product of two 2 vectors */
double icmDot2(double in1[2], double in2[2]);
#define ICMDOT2(o, i, j) ((o) = (i)[0] * (j)[0] + (i)[1] * (j)[1])
/* Compute the dot product of two 2 vectors defined by 4 points */
/* 1->2 and 3->4 */
double icmDot22(double in1[2], double in2[2], double in3[2], double in4[2]);
/* Normalise a 2 vector to the given length. Return nz if not normalisable */
int icmNormalize2(double out[2], double in[2], double len);
/* Return an orthogonal vector */
void icmOrthog2(double out[2], double in[2]);
/* Given 2 2D points, compute a plane equation. */
/* The normal will be right handed given the order of the points */
/* The plane equation will be the 2 normal components and the constant. */
/* Return nz if any points are cooincident or co-linear */
int icmPlaneEqn2(double eq[3], double p0[2], double p1[2]);
/* Given a 2D point and a plane equation, return the signed */
/* distance from the plane */
double icmPlaneDist2(double eq[3], double p[2]);
/* Return the closest point on an implicit line to a point. */
/* Also return the absolute distance */
double icmImpLinePointClosest2(double cp[2], double eq[3], double pp[2]);
/* Return the point of intersection of two implicit lines . */
/* Return nz if there is no intersection (lines are parallel) */
int icmImpLineIntersect2(double res[2], double eq1[3], double eq2[3]);
/* Compute the closest point on a line to a point. */
/* Return closest point and parameter value if not NULL. */
/* Return nz if the line length is zero */
int icmLinePointClosest2(double cp[2], double *pa,
double la0[2], double la1[2], double pp[2]);
/* Given two infinite 2D lines define by two pairs of points, compute the intersection. */
/* Return nz if there is no intersection (lines are parallel) */
int icmLineIntersect2(double res[2], double p1[2], double p2[2], double p3[2], double p4[2]);
/* Given two finite 2D lines define by 4 points, compute their paramaterized intersection. */
/* res[] and/or aprm[] may be NULL. Param is prop. from p1 -> p2, p3 -> p4 */
/* Return 2 if there is no intersection (lines are parallel) */
/* Return 1 lines do not cross within their length */
int icmParmLineIntersect2(double ares[2], double aprm[2], double p1[2], double p2[2], double p3[2], double p4[2]);
/* Set a 2x2 matrix to unity */
void icmSetUnity2x2(double mat[2][2]);
/* Invert a 2x2 transform matrix. Return 1 if error. */
int icmInverse2x2(double out[2][2], double in[2][2]);
/* Compute a blend between in0 and in1 for bl 0..1 */
void icmBlend2(double out[2], double in0[2], double in1[2], double bf);
/* Scale a 2 vector by the given ratio */
void icmScale2(double out[2], double in[2], double rat);
/* Scale a 2 vector by the given ratio and add it */
void icmScaleAdd2(double out[2], double in2[3], double in1[2], double rat);
/* Convert orientation 0 = right, 1 = down, 2 = left, 3 = right */
/* into rotation matrix */
static void icmOr2mat(double mat[2][2], int or);
/* Convert an angle in radians into rotation matrix (0 = right) */
void icmRad2mat(double mat[2][2], double rad);
/* Convert an angle in degrees (0 = right) into rotation matrix */
void icmDeg2mat(double mat[2][2], double a);
/* Convert a vector into a rotation matrix */
void icmVec2mat(double mat[2][2], double dx, double dy);
/* Multiply 2 array by 2x2 transform matrix */
void icmMulBy2x2(double out[2], double mat[2][2], double in[2]);
/* - - - - - - - - - - - - - - */
/* General vector functions */
/* Set a vector to a single value */
void icmSetN(double *dst, double src, int len);
/* Copy a vector */
//void icmCpyN(double *dst, double *src, int len);
#define icmCpyN(dst, src, len) memmove((char *)(dst), (char *)(src), (len) * sizeof(double))
/* Clip a vector to the range 0.0 .. 1.0 */
void icmClipN(double out[3], double in[3], unsigned int len);
/* Clip a vector to the range 0.0 .. 1.0 */
/* and return any clipping margine over the limit */
double icmClipNmarg(double *out, double *in, unsigned int len);
/* Return the magnitude (norm) of the difference between two vectors */
double icmDiffN(double *s1, double *s2, int len);
/* ----------------------------------------------- */
/* Structure to hold pseudo-hilbert counter info */
struct _psh {
int di; /* Dimensionality */
unsigned int res[MAX_CHAN]; /* Resolution per coordinate */
unsigned int bits[MAX_CHAN]; /* Bits per coordinate */
unsigned int xbits; /* Max of bits[] */
unsigned int tbits; /* Total bits */
unsigned int tmask; /* Total 2^tbits count mask */
unsigned int count; /* Usable count */
unsigned int ix; /* Current binary index */
int diag; /* nz if generating singe diagnostic index */
}; typedef struct _psh psh;
/* Initialise a pseudo-hilbert grid counter, return total usable count. */
extern ICCLIB_API unsigned psh_init(psh *p, int di, unsigned int res, int co[]);
/* Same as above but with variable res per axis. */
extern ICCLIB_API unsigned psh_initN(psh *p, int di, unsigned int res[], int co[]);
/* Diagnostic init - psh returns the value in co[] and then terminates */
extern ICCLIB_API unsigned psh_init_diag(psh *p, int di, int co[]);
/* Reset the counter */
extern ICCLIB_API void psh_reset(psh *p);
/* Increment pseudo-hilbert coordinates */
/* Return non-zero if count rolls over to 0 */
extern ICCLIB_API int psh_inc(psh *p, int co[]);
/* - - - - - - - - - - - - - - */
/* Simple macro to transfer an array to an XYZ number */
#define icmAry2XYZ(xyz, ary) ((xyz).X = (ary)[0], (xyz).Y = (ary)[1], (xyz).Z = (ary)[2])
/* And the reverse */
#define icmXYZ2Ary(ary, xyz) ((ary)[0] = (xyz).X, (ary)[1] = (xyz).Y, (ary)[2] = (xyz).Z)
/* Simple macro to transfer an XYZ number to an XYZ number */
#define icmXYZ2XYZ(d_xyz, s_xyz) ((d_xyz).X = (s_xyz).X, (d_xyz).Y = (s_xyz).Y, \
(d_xyz).Z = (s_xyz).Z)
/* Simple macro to transfer an 3array to 3array */
/* Hmm. Same as icmCpy3 */
#define icmAry2Ary(d_ary, s_ary) ((d_ary)[0] = (s_ary)[0], (d_ary)[1] = (s_ary)[1], \
(d_ary)[2] = (s_ary)[2])
/* CIE Y (range 0 .. 1) to perceptual CIE 1976 L* (range 0 .. 100) */
double icmY2L(double val);
/* Perceptual CIE 1976 L* (range 0 .. 100) to CIE Y (range 0 .. 1) */
double icmL2Y(double val);
/* CIE XYZ to perceptual Lab */
extern ICCLIB_API void icmXYZ2Lab(icmXYZNumber *w, double *out, double *in);
/* Perceptual Lab to CIE XYZ */
extern ICCLIB_API void icmLab2XYZ(icmXYZNumber *w, double *out, double *in);
/* CIE XYZ to perceptual Lpt */
extern ICCLIB_API void icmXYZ2Lpt(icmXYZNumber *w, double *out, double *in);
/* Perceptual Lpt to CIE XYZ */
extern ICCLIB_API void icmLpt2XYZ(icmXYZNumber *w, double *out, double *in);
/* LCh to Lab (general) */
extern ICCLIB_API void icmLCh2Lab(double *out, double *in);
/* Lab to LCh (general) */
extern ICCLIB_API void icmLab2LCh(double *out, double *in);
/* CIE XYZ to perceptual Luv */
extern ICCLIB_API void icmXYZ2Luv(icmXYZNumber *w, double *out, double *in);
/* Perceptual Luv to CIE XYZ */
extern ICCLIB_API void icmLuv2XYZ(icmXYZNumber *w, double *out, double *in);
/* XYZ to Yxy */
extern ICCLIB_API void icmXYZ2Yxy(double *out, double *in);
/* Yxy to XYZ */
extern ICCLIB_API void icmYxy2XYZ(double *out, double *in);
/* XYZ to xy */
extern ICCLIB_API void icmXYZ2xy(double *out, double *in);
/* Y & xy to XYZ */
extern ICCLIB_API void icmY_xy2XYZ(double *out, double *xy, double Y);
/* CIE XYZ to perceptual CIE 1976 UCS diagram Yu'v'*/
/* (Yu'v' is a better linear chromaticity space than Yxy) */
extern ICCLIB_API void icmXYZ21976UCS(double *out, double *in);
/* Perceptual CIE 1976 UCS diagram Yu'v' to CIE XYZ */
extern ICCLIB_API void icm1976UCS2XYZ(double *out, double *in);
/* CIE XYZ to perceptual CIE 1976 UCS diagram u'v'*/
/* (u'v' is a better linear chromaticity space than xy) */
extern ICCLIB_API void icmXYZ21976UCSuv(double *out, double *in);
/* CIE 1976 UCS diagram Y & u'v' to XYZ */
extern ICCLIB_API void icm1976UCSY_uv2XYZ(double *out, double *uv, double Y);
/* Aliases for above */
#define icmXYZ2Yuv icmXYZ21976UCS
#define icmYuv2XYZ icm1976UCS2XYZ
#define icmXYZ2uv icmXYZ21976UCSuv
#define icmY_uv2XYZ icm1976UCSY_uv2XYZ
/* CIE XYZ to perceptual CIE 1960 UCS */
/* (This was obsoleted by the 1976UCS, but is still used */
/* in computing color temperatures.) */
extern ICCLIB_API void icmXYZ21960UCS(double *out, double *in);
/* Perceptual CIE 1960 UCS to CIE XYZ */
extern ICCLIB_API void icm1960UCS2XYZ(double *out, double *in);
/* CIE XYZ to perceptual CIE 1964 WUV (U*V*W*) */
/* (This is obsolete but still used in computing CRI) */
extern ICCLIB_API void icmXYZ21964WUV(icmXYZNumber *w, double *out, double *in);
/* Perceptual CIE 1964 WUV (U*V*W*) to CIE XYZ */
extern ICCLIB_API void icm1964WUV2XYZ(icmXYZNumber *w, double *out, double *in);
/* CIE CIE1960 UCS to perceptual CIE 1964 WUV (U*V*W*) */
extern ICCLIB_API void icm1960UCS21964WUV(icmXYZNumber *w, double *out, double *in);
/* NOTE :- that these values are for the 1931 standard observer */
/* The standard D50 illuminant value */
extern icmXYZNumber icmD50;
extern icmXYZNumber icmD50_100; /* Scaled to 100 */
extern double icmD50_ary3[3]; /* As an array */
extern double icmD50_100_ary3[3]; /* Scaled to 100 as an array */
/* The standard D65 illuminant value */
extern icmXYZNumber icmD65;
extern icmXYZNumber icmD65_100; /* Scaled to 100 */
extern double icmD65_ary3[3]; /* As an array */
extern double icmD65_100_ary3[3]; /* Scaled to 100 as an array */
/* The default black value */
extern icmXYZNumber icmBlack;
/* The Standard ("wrong Von-Kries") chromatic transform matrix */
extern double icmWrongVonKries[3][3];
/* The Bradford chromatic transform matrix */
extern double icmBradford[3][3];
/* ----------------------------------------------- */
/* - - - - - - - - - - - - - - - - - - - - - - - */
/* Return the normal Delta E given two Lab values */
extern ICCLIB_API double icmLabDE(double *in0, double *in1);
/* Return the normal Delta E squared, given two Lab values */
extern ICCLIB_API double icmLabDEsq(double *in0, double *in1);
/* Return the normal Delta E squared given two XYZ values */
extern ICCLIB_API double icmXYZLabDEsq(icmXYZNumber *w, double *in0, double *in1);
/* Return the normal Delta E given two XYZ values */
extern ICCLIB_API double icmXYZLabDE(icmXYZNumber *w, double *in0, double *in1);
/* Return the normal Delta E squared given two XYZ values */
extern ICCLIB_API double icmXYZLptDEsq(icmXYZNumber *w, double *in0, double *in1);
/* Return the normal Delta E given two XYZ values */
extern ICCLIB_API double icmXYZLptDE(icmXYZNumber *w, double *in0, double *in1);
/* Return the CIE94 Delta E color difference measure for two Lab values */
extern ICCLIB_API double icmCIE94(double *in0, double *in1);
/* Return the CIE94 Delta E color difference measure squared, for two Lab values */
extern ICCLIB_API double icmCIE94sq(double *in0, double *in1);
/* Return the CIE94 Delta E color difference measure for two XYZ values */
extern ICCLIB_API double icmXYZCIE94(icmXYZNumber *w, double *in0, double *in1);
/* Return the CIEDE2000 Delta E color difference measure for two Lab values */
extern ICCLIB_API double icmCIE2K(double *in0, double *in1);
/* Return the CIEDE2000 Delta E color difference measure squared, for two Lab values */
extern ICCLIB_API double icmCIE2Ksq(double *in0, double *in1);
/* Return the CIEDE2000 Delta E color difference measure for two XYZ values */
extern ICCLIB_API double icmXYZCIE2K(icmXYZNumber *w, double *in0, double *in1);
/* - - - - - - - - - - - - - - - - - - - - - - - */
/* Clip Lab, while maintaining hue angle. */
/* Return nz if clipping occured */
int icmClipLab(double out[3], double in[3]);
/* Clip XYZ, while maintaining hue angle */
/* Return nz if clipping occured */
int icmClipXYZ(double out[3], double in[3]);
/* - - - - - - - - - - - - - - - - - - - - - - - */
/* RGB XYZ primaries to device to RGB->XYZ transform matrix */
/* Return non-zero if matrix would be singular */
/* Use icmMulBy3x3(dst, mat, src) */
int icmRGBXYZprim2matrix(
double red[3], /* Red colorant */
double green[3], /* Green colorant */
double blue[3], /* Blue colorant */
double white[3], /* White point */
double mat[3][3] /* Destination matrix[RGB][XYZ] */
);
/* RGB Yxy primaries to device to RGB->XYZ transform matrix */
/* Return non-zero if matrix would be singular */
/* Use icmMulBy3x3(dst, mat, src) */
int icmRGBYxyprim2matrix(
double red[3], /* Red colorant */
double green[3], /* Green colorant */
double blue[3], /* Blue colorant */
double white[3], /* White point */
double mat[3][3], /* Return matrix[RGB][XYZ] */
double wXYZ[3] /* Return white XYZ */
);
/* Chromatic Adaption transform utility */
/* Return a 3x3 chromatic adaption matrix */
/* Use icmMulBy3x3(dst, mat, src) */
/* [ use icc->chromAdaptMatrix() to use the profiles cone space matrix rather */
/* than specify a CAM ] */
#define ICM_CAM_NONE 0x0000 /* No flags */
#define ICM_CAM_BRADFORD 0x0001 /* Use Bradford sharpened response space */
#define ICM_CAM_MULMATRIX 0x0002 /* Transform the given matrix rather than */
/* create a transform from scratch. */
/* NOTE that to transform primaries they */
/* must be mat[XYZ][RGB] format! */
void icmChromAdaptMatrix(
int flags, /* Flags as defined below */
icmXYZNumber d_wp, /* Destination white point */
icmXYZNumber s_wp, /* Source white point */
double mat[3][3] /* Destination matrix */
);
/* Pre-round RGB device primary values to ensure that */
/* the sum of the quantized primaries is the same as */
/* the quantized sum. */
void quantizeRGBprimsS15Fixed16(
double mat[3][3] /* matrix[RGB][XYZ] */
);
/* Pre-round a 3x3 matrix to ensure that the product of */
/* the matrix and the input value is the same as */
/* the quantized matrix product. This is used to improve accuracy */
/* of 'chad' tag in computing absolute white point. */
void icmQuantize3x3S15Fixed16(
double targ[3], /* Target of product */
double mat[3][3], /* matrix[][] to be quantized */
double in[3] /* Input of product - must not be 0.0! */
);
/* - - - - - - - - - - - - - - */
/* Video functions */
/* Convert Lut table index/value to YCbCr */
void icmLut2YCbCr(double *out, double *in);
/* Convert YCbCr to Lut table index/value */
void icmYCbCr2Lut(double *out, double *in);
/* Convert Rec601 RGB' into YPbPr, (== "full range YCbCr") */
/* where input 0..1, output 0..1, -0.5 .. 0.5, -0.5 .. 0.5 */
void icmRec601_RGBd_2_YPbPr(double out[3], double in[3]);
/* Convert Rec601 YPbPr to RGB' (== "full range YCbCr") */
/* where input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, output 0.0 .. 1 */
void icmRec601_YPbPr_2_RGBd(double out[3], double in[3]);
/* Convert Rec709 1150/60/2:1 RGB' into YPbPr, or "full range YCbCr" */
/* where input 0..1, output 0..1, -0.5 .. 0.5, -0.5 .. 0.5 */
void icmRec709_RGBd_2_YPbPr(double out[3], double in[3]);
/* Convert Rec709 1150/60/2:1 YPbPr to RGB' (== "full range YCbCr") */
/* where input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, output 0.0 .. 1 */
void icmRec709_YPbPr_2_RGBd(double out[3], double in[3]);
/* Convert Rec709 1250/50/2:1 RGB' into YPbPr, or "full range YCbCr" */
/* where input 0..1, output 0..1, -0.5 .. 0.5, -0.5 .. 0.5 */
void icmRec709_50_RGBd_2_YPbPr(double out[3], double in[3]);
/* Convert Rec709 1250/50/2:1 YPbPr to RGB' (== "full range YCbCr") */
/* where input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, output 0.0 .. 1 */
void icmRec709_50_YPbPr_2_RGBd(double out[3], double in[3]);
/* Convert Rec2020 RGB' into Non-constant liminance YPbPr, or "full range YCbCr" */
/* where input 0..1, output 0..1, -0.5 .. 0.5, -0.5 .. 0.5 */
void icmRec2020_NCL_RGBd_2_YPbPr(double out[3], double in[3]);
/* Convert Rec2020 Non-constant liminance YPbPr into RGB' (== "full range YCbCr") */
/* where input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, output 0.0 .. 1 */
void icmRec2020_NCL_YPbPr_2_RGBd(double out[3], double in[3]);
/* Convert Rec2020 RGB' into Constant liminance YPbPr, or "full range YCbCr" */
/* where input 0..1, output 0..1, -0.5 .. 0.5, -0.5 .. 0.5 */
void icmRec2020_CL_RGBd_2_YPbPr(double out[3], double in[3]);
/* Convert Rec2020 Constant liminance YPbPr into RGB' (== "full range YCbCr") */
/* where input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, output 0.0 .. 1 */
void icmRec2020_CL_YPbPr_2_RGBd(double out[3], double in[3]);
/* Convert Rec601/709/2020 YPbPr to YCbCr range. */
/* input 0..1, -0.5 .. 0.5, -0.5 .. 0.5, */
/* output 16/255 .. 235/255, 16/255 .. 240/255, 16/255 .. 240/255 */
void icmRecXXX_YPbPr_2_YCbCr(double out[3], double in[3]);
/* Convert Rec601/709/2020 YCbCr to YPbPr range. */
/* input 16/255 .. 235/255, 16/255 .. 240/255, 16/255 .. 240/255 */
/* output 0..1, -0.5 .. 0.5, -0.5 .. 0.5, */
void icmRecXXX_YCbCr_2_YPbPr(double out[3], double in[3]);
/* Convert full range RGB to Video range 16..235 RGB */
void icmRGB_2_VidRGB(double out[3], double in[3]);
/* Convert Video range 16..235 RGB to full range RGB */
void icmVidRGB_2_RGB(double out[3], double in[3]);
/* ---------------------------------------------------------- */
/* PS 3.14-2009, Digital Imaging and Communications in Medicine */
/* (DICOM) Part 14: Grayscale Standard Display Function */
/* JND index value 1..1023 to L 0.05 .. 3993.404 cd/m^2 */
double icmDICOM_fwd(double jnd);
/* L 0.05 .. 3993.404 cd/m^2 to JND index value 1..1023 */
double icmDICOM_bwd(double L);
/* ---------------------------------------------------------- */
/* Some utility functions */
/* Convert an angle in radians into chromatic RGB values */
/* in a simple geometric fashion with 0 = Red */
void icmRad2RGB(double rgb[3], double ang);
/* ---------------------------------------------------------- */
/* UTF conversion functions with checking. */
/* Heavily modified from Unicode, Inc. code, Author: Mark E. Davis, 1994. */
/* see corresponding icc.c for full credits and copyright */
/* Error and warning codes from conversions */
typedef enum {
icmUTF_ok = 0x00000, /* ok */
icmUTF_emb_nul = 0x00001, /* embedded nul */
/* UTF-16 errors */
icmUTF_no_nul = 0x00002, /* no nul terminator */
icmUTF_unex_nul = 0x00004, /* unexpected nul terminator */
icmUTF_prem_nul = 0x00008, /* nul before end */
icmUTF_bad_surr = 0x00010, /* badly formed surrogate pair */
icmUTF_unn_bom = 0x00020, /* unecessary Byte Order Mark */
icmUTF_odd_bytes = 0x00040, /* length is odd number of bytes */
/* UTF-8 errors */
icmUTF_unex_cont = 0x00080, /* unexpected continuation byte */
icmUTF_tmany_cont = 0x00100, /* too many continuation bytes */
icmUTF_short_cont = 0x00200, /* continuation bytes are cut short */
icmUTF_overlong = 0x00400, /* overlong encoding */
icmUTF_inv_cdpnt = 0x00800, /* invalid code point - UTF-16 surrogate */
icmUTF_ovr_cdpnt = 0x01000, /* invalid code point - greater than unicode maximum */
/* ASCII errors */
icmUTF_non_ascii = 0x02000, /* found non-ascii character in UTF-8 */
icmUTF_ascii_toolong = 0x04000, /* ASCII longer than fixed sized buffer */
/* ScriptCode errors */
icmUTF_sc_tooshort = 0x08000, /* ScriptCode size < 67 */
icmUTF_sc_toolong = 0x10000 /* ScriptCode size > 67 */
} icmUTFerr;
/* Serialisation */
size_t icmUTF16SntoUTF8(icmUTFerr *pillegal, icmUTF8 *out, icmFBuf *bin, size_t len, int nonul);
size_t icmUTF8toUTF16Sn(icmUTFerr *pillegal, icmFBuf *bout, icmUTF8 *in, size_t len, int nonul);
size_t icmASCIIZSntoUTF8(icmUTFerr *pillegal, icmUTF8 *out, icmFBuf *bin, size_t len, int fxlen);
size_t icmUTF8toASCIIZSn(icmUTFerr *pillegal, icmFBuf *bout, icmUTF8 *in, size_t len, int fxlen);
size_t icmSntoScriptCode(icmUTFerr *pillegal, icmUTF8 *out, icmFBuf *bin, size_t len);
size_t icmScriptCodetoSn(icmUTFerr *pillegal, icmFBuf *bout, ORD8 *in, size_t len);
/* General convert UTF16 to UTF8. */
/* Repairs UTF16 string to be legal UTF-8. */
/* Input is expected to be nul terminated. */
/* Output will be nul terminated. */
/* Return resulting size in bytes including nul. */
/* out pointer can be NULL to size buffer. */
/* pillegal can be NULL. */
size_t icmUTF16toUTF8(icmUTFerr *pillegal, icmUTF8 *out, icmUTF16 *in);
size_t icmUTF8toUTF16(icmUTFerr *pillegal, icmUTF16 *out, icmUTF8 *in);
/* Convert utf-8 to HTML escapes. illegal will have icmUTF_non_ascii set if any non-ASCII found. */
/* All output pointers may be NULL */
size_t icmUTF8toHTMLESC(icmUTFerr *pillegal, char *out, icmUTF8 *in);
/* Convert UTF-8 to ASCII. Out of range characters are replaced by '?'. */
/* illegal will have icmUTF_non_ascii set if any non-ASCII found. */
/* All output pointers may be NULL */
size_t icmUTF8toASCII(icmUTFerr *pillegal, char *out, icmUTF8 *in);
/* Convert icmUTFerr to a comma separated list of error descriptions. */
char *icmUTFerr2str(icmUTFerr err);
/* ---------------------------------------------------------- */
/* Print an int vector to a string. */
/* Returned static buffer is re-used every 5 calls. */
char *icmPiv(int di, int *p);
/* Print a double color vector to a string. */
/* Returned static buffer is re-used every 5 calls. */
char *icmPdv(int di, double *p);
/* Print a double color vector to a string with format. */
/* Returned static buffer is re-used every 5 calls. */
char *icmPdvf(int di, char *fmt, double *p);
/* Print a float color vector to a string. */
/* Returned static buffer is re-used every 5 calls. */
char *icmPfv(int di, float *p);
/* Print an XYZ */
/* Returned static buffer is re-used every 5 calls. */
char *icmPXYZ(icmXYZNumber *p);
/* Print an 0..1 range XYZ as a D50 Lab string */
/* Returned static buffer is re-used every 5 calls. */
char *icmPLab(double *p);
/* ---------------------------------------------------------- */
/* Cause a debug break or stack trace */
#ifndef DEBUG_BREAK
# ifdef NT
# define DEBUG_BREAK DebugBreak()
# else
# if defined(__APPLE__)
// extern void Debugger();
//# define DEBUG_BREAK Debugger() // deprecated ?
//extern void __debugbreak();
//# define DEBUG_BREAK __debugbreak()
# define DEBUG_BREAK *((volatile char *)0) = 0x55;
# else
# include <signal.h>
# if defined(SIGTRAP)
# define DEBUG_BREAK raise(SIGTRAP)
# else
# define DEBUG_BREAK raise(SIGABRT)
# endif
# endif
# endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* ICC_UTIL_H */

4738
Argyll_V3.5.0/icc/icc_xf.c Normal file

File diff suppressed because it is too large Load Diff

220
Argyll_V3.5.0/icc/icc_xf.h Normal file
View File

@@ -0,0 +1,220 @@
/* ================================================= */
/* icmPe transform declarations */
/* This is #included in icc.h */
typedef enum { /* Lab version encoding */
icmEncV2 = 0, /* ICC V2 */
icmEncProf = 2 /* Same as icc header version */
} icmEncLabVer;
typedef enum { /* Lab version representation */
icmEncNbit = 0, /* 32 bit float or 16.16 */
icmEnc8bit = 1, /* 8 bit */
icmEnc16bit = 2 /* 16 bit */
} icmEncBytes;
/* Given a full range colorspace sig, return a default value ranges. */
/* Return NZ if range is not 0.0 - 1.0 */
int icmGetDefaultFullRange(
struct _icc *icp,
double *min, double *max, /* Return range */
icColorSpaceSignature sig /* Full range colorspace sig */
);
/* Clip the given PCS value to be within the 16 bit encodable range */
/* Return nz if clipped */
static int icmClipPCS16(
struct _icc *icp,
double out[3],
double in[3],
icColorSpaceSignature encSpace,
icmEncLabVer ver /* 0 = V2, 2 same as profile */
);
/* A structure for returning information about a colorspace */
typedef struct {
icColorSpaceSignature sig; /* Signature */
int nch; /* Number of channels */
double min[MAX_CHAN]; /* Nominal range of each channel */
double max[MAX_CHAN];
} icmCSInfo;
/* Lookup class members common to named and non-named color types */
#define LU4_ICM_BASE_MEMBERS(TCLASS) \
\
/* Private: */ \
icmLu4Type ttype; /* The type of object */ \
struct _icc *icp; /* Pointer to ICC we're a part of */ \
icTagSignature sourceTag; /* The transform source tag */ \
icRenderingIntent intent; /* Effective (externaly visible) intent */ \
icmLookupFunc function; /* Functionality being used */ \
icmLookupOrder order; /* Conversion representation search Order */ \
icmPeOp op; /* lookup op */ \
int can_bwd; /* nz if lookup_bwd will work */ \
icmXYZNumber pcswht; /* PCS White, i.e. D50 (abs. XYZ) */ \
icmXYZNumber whitePoint, blackPoint;/* Profile White and black point (abs. XYZ) */ \
int blackisassumed; /* nz if black point tag is missing from profile */ \
double toAbs[3][3]; /* Matrix to convert from relative to absolute */ \
double fromAbs[3][3]; /* Matrix to convert from absolute to relative */ \
icmCSInfo ini; /* Native Clr space of input info. */ \
icmCSInfo outi; /* Native Clr space of output info. */ \
icmCSInfo pcsi; /* Native PCS info. */ \
icmCSInfo e_ini; /* Effective Clr space of input info. */ \
icmCSInfo e_outi; /* Effective Clr space of output info. */ \
icmCSInfo e_pcsi; /* Effective PCS info. */ \
/* Hmm. Do we need in/out/e_ abs intent flags ? */ \
\
/* Public: */ \
\
void (*del)(TCLASS *p); \
\
/* Initialise the white and black points from the ICC tags, */ \
/* and the corresponding absolute<->relative conversion matrices. */ \
/* (Called on init, and after white & black set during creation.) */ \
/* Return nz on error */ \
\
int (*init_wh_bk)(TCLASS *p); \
\
/* External effecive colorspaces and other lookup information */ \
void (*spaces) (TCLASS *p, icmCSInfo *ini, icmCSInfo *outi, icmCSInfo *pcsi, \
icTagSignature *srctag, icRenderingIntent *intt, \
icmLookupFunc *fnc, icmLookupOrder *ord, \
icmPeOp *op, int *can_bwd); \
\
/* Internal native colorspaces: */ \
void (*native_spaces) (TCLASS *p, icmCSInfo *ini, icmCSInfo *outi, icmCSInfo *pcsi);\
\
/* Relative to Absolute for this WP in XYZ */ \
void (*XYZ_Rel2Abs)(TCLASS *p, double *xyzout, double *xyzin); \
\
/* Absolute to Relative for this WP in XYZ */ \
void (*XYZ_Abs2Rel)(TCLASS *p, double *xyzout, double *xyzin); \
/* Base lookup object */
struct _icmLu4Base {
LU4_ICM_BASE_MEMBERS(struct _icmLu4Base)
}; // typedef struct _icmLu4Base icmLu4Base;
/* Colorspace lookup class (not named color) */
struct _icmLu4Space {
LU4_ICM_BASE_MEMBERS(struct _icmLu4Space)
/* Private: */
/* Note that these icmPeContainers will all be flat - */
/* i.e. there will be no sub-icmPeSeq's, only icmPeInverter's */
/* single stage transform */
icmPeContainer *lookup; /* Overall transform */
/* 3 stage transforms */
icmPeContainer *input; /* Per channel pre-transforms */
icmPeContainer *core3; /* Core transform that may change no. channels */
icmPeContainer *output; /* Per channel post-transforms */
/* 5 stage transforms */
icmPeContainer *input_fmt; /* PCS and abs. conversion */
icmPeContainer *input_pch; /* Per channel pre-transforms */
icmPeContainer *core5; /* Core transform that may change no. channels */
icmPeContainer *output_pch; /* Per channel post-transforms */
icmPeContainer *output_fmt; /* PCS and abs. conversion */
/* Public: */
/* Get the LU PCS white, white and black points in absolute XYZ space. */
/* PCS will be the profile header PCS white point. */
/* Return nz if the black point is being assumed to be 0,0,0 rather */
/* than being from the tag. */
int (*wh_bk_points)(struct _icmLu4Space *p, double *pcs, double *wht, double *blk);
/* Get the LU PCS white, white and black points in LU PCS space, converted to XYZ. */
/* (ie. white and black will be relative if LU is relative intent etc.) */
/* Return nz if the black point is being assumed to be 0,0,0 rather */
/* than being from the tag. */
int (*lu_wh_bk_points)(struct _icmLu4Space *p, double *pcs, double *wht, double *blk);
/* Overall transforms */
icmPe_lurv (*lookup_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*lookup_bwd) (struct _icmLu4Space *p, double *out, double *in);
/* 3 stage transforms are fmt&per-channel + core + per-channel&fmt: */
/* 3 stage components of fwd lookup */
icmPe_lurv (*input_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*core3_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*output_fwd) (struct _icmLu4Space *p, double *out, double *in);
/* 3 stage cComponents of bwd lookup */
icmPe_lurv (*output_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*core3_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*input_bwd) (struct _icmLu4Space *p, double *out, double *in);
/* 5 stage transforms are fmt + per-channel + core + per-channel + fmt: */
/* 5 stage sub-components of input_fwd and output_fwd lookup */
icmPe_lurv (*input_fmt_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*input_pch_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*core5_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*output_pch_fwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*output_fmt_fwd) (struct _icmLu4Space *p, double *out, double *in);
/* 5 stage sub-components of input_bwd and output_bwd lookup */
icmPe_lurv (*output_fmt_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*output_pch_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*core5_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*input_pch_bwd) (struct _icmLu4Space *p, double *out, double *in);
icmPe_lurv (*input_fmt_bwd) (struct _icmLu4Space *p, double *out, double *in);
/* Lookup information */
/* Find the largest per channel input lut resolution. */
/* res may be NULL */
/* Returns 0 if there is no per channel lut in the input sequence. */
unsigned int (*max_in_res)(struct _icmLu4Space *p, int res[MAX_CHAN]);
/* Find the largest cLUT clutPoints[] value. */
/* res may be NULL */
/* Returns 0 if there is no cLut transform in the sequence. */
unsigned int (*max_clut_res)(struct _icmLu4Space *p, int res[MAX_CHAN]);
/* Find the largest per channel output lut resolution. */
/* res may be NULL */
/* Returns 0 if there is no per channel lut in the output sequence. */
unsigned int (*max_out_res)(struct _icmLu4Space *p, int res[MAX_CHAN]);
/* Determine if the per channel input or output is likely to be */
/* in a linear light space. We do this by seeing if the first */
/* non-per channel or format element is a matrix or matrix like */
/* element, and if the PCS is XYZ. This is not totally reliable, but */
/* should work for simple matrix device profiles. */
/* Return nz if true */
/* dir should be 0 if for if we are interested in the input characteristic, */
/* and nz if we are interested in the output characteristic. */
/* (We assume that the icmPeContainer is flattened) */
int (*linear_light_inout)(struct _icmLu4Space *p, int dir);
/* Return a pointer to the last icmPeLut in the lookup_fwd and */
/* a Seq containing the transforms from the output of the Lut */
/* Return NULL if no icmPeLut */
/* Delete both objects when done */
icmPeClut *(*get_lut)(
struct _icmLu4Space *p,
icmPeContainer **ptail /* If not NULL return tail process, NULL if none */
);
/* Return total ink limit and channel maximums. */
/* return -1.0 if this lu doesn't have an icmPeClut in it. */
double (*get_tac)(
struct _icmLu4Space *p,
double *chmax, /* device return channel maximums. May be NULL */
void (*calfunc)(void *cntx, double *out, double *in), /* Optional calibration func. */
void *cntx
);
}; // typedef struct _icmLu4Space icmLu4Space;
/* Fake up alg from icmLu4 attributes */
icmLuAlgType icmSynthAlgType(icmLuBase *p);

332
Argyll_V3.5.0/icc/iccdump.c Normal file
View File

@@ -0,0 +1,332 @@
/*
* International Color Consortium Format Library (icclib)
* File dump utility.
*
* Author: Graeme W. Gill
* Date: 1999/11/29
* Version: 2.15
*
* Copyright 1997 - 2012 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/*
* TTBD:
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include "icc.h"
void error(char *fmt, ...), warning(char *fmt, ...);
void usage(void) {
fprintf(stderr,"Dump an ICC file in human readable form, V%s\n",ICCLIB_VERSION_STR);
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: iccdump [-v level] [-t tagname] [-s] infile\n");
fprintf(stderr," -v level Verbose level 1-3 (default 2)\n");
fprintf(stderr," -t tag Dump this tag only (can be used multiple times)\n");
fprintf(stderr," -s Search for embedded profile\n");
fprintf(stderr," -i Check V4 ID value\n");
fprintf(stderr," -w Warn of ICC format problems to stdout\n");
fprintf(stderr," -W Warn of ICC format problems to stderr\n");
fprintf(stderr," -S Be strict about ICC format\n");
exit(1);
}
FILE *warnout;
/* Warning callback function */
void dump_warning(icc *p, int err, const char *format, va_list vp) {
fprintf(warnout, "Warning (0x%x): ",err);
vfprintf(warnout, format, vp);
fprintf(warnout, "\n");
}
#define MXTGNMS 30
int
main(int argc, char *argv[]) {
int fa,nfa; /* argument we're looking at */
static char in_name[MAXNAMEL+1];
int ntag_names = 0;
char tag_names[MXTGNMS][5];
int verb = 2; /* Default = moderate (some from individual tags) */
int search = 0;
int chid = 0; /* Check V4 ID */
int strict = 0; /* Be strict about ICC format */
int warnings = 0; /* Warn of format problems */
int ecount = 1; /* Embedded count */
int offset = 0; /* Offset to read profile from */
int found;
icmErr err = { 0, { '\000' }};
icmFile *fp, *op;
icc *icco;
int rv = 0;
if (argc < 2)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
if (argv[fa][1] == '?')
usage();
/* Verbosity */
else if (argv[fa][1] == 'v') {
fa = nfa;
if (na == NULL) usage();
verb = atoi(na);
}
/* Tag name */
else if (argv[fa][1] == 't') {
fa = nfa;
if (na == NULL) usage();
if (ntag_names >= MXTGNMS)
usage();
strncpy(tag_names[ntag_names],na,4);
tag_names[ntag_names++][4] = '\000';
}
/* Search */
else if (argv[fa][1] == 's') {
search = 1;
}
/* Check ID */
else if (argv[fa][1] == 'i') {
chid = 1;
}
/* Warnings */
else if (argv[fa][1] == 'w') {
warnings = 1;
warnout = stdout;
}
else if (argv[fa][1] == 'W') {
warnings = 1;
warnout = stderr;
}
/* Strict */
else if (argv[fa][1] == 'S') {
strict = 1;
}
else
usage();
}
else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strncpy(in_name,argv[fa++],MAXNAMEL); in_name[MAXNAMEL] = '\000';
/* Open up the file for reading */
if ((fp = new_icmFileStd_name(&err, in_name,"r")) == NULL)
error ("Can't open file '%s' failed with 0x%x, '%s'",in_name, err.c, err.m);
if ((icco = new_icc(&err)) == NULL)
error ("Creation of ICC object failed with 0x%x, '%s'", err.c, err.m);
if (strict)
icco->unset_cflag(icco, icmCFlagRdFormatWarn
| icmCFlagRdVersionWarn
| icmCFlagRdAllowUnknown
| icmCFlagAllowExtensions);
/* Install warning message handler */
if (warnings)
icco->warning = dump_warning;
/* open output stream */
if ((op = new_icmFileStd_fp(&err, stdout)) == NULL)
error ("Can't open stdout stream, failed with 0x%x, '%s'",err.c, err.m);
do {
found = 0;
/* Dumb search for magic number */
if (search) {
int fc = 0;
char c;
if (fp->seek(fp, offset) != 0)
break;
while(found == 0) {
if (fp->read(fp, &c, 1, 1) != 1) {
break;
}
offset++;
switch (fc) {
case 0:
if (c == 'a')
fc++;
else
fc = 0;
break;
case 1:
if (c == 'c')
fc++;
else
fc = 0;
break;
case 2:
if (c == 's')
fc++;
else
fc = 0;
break;
case 3:
if (c == 'p') {
found = 1;
offset -= 40;
}
else
fc = 0;
break;
}
}
}
if (search == 0 || found != 0) {
ecount++;
if (search)
printf("Embedded profile found at file offset %d (0x%x)\n",offset,offset);
if ((rv = icco->read(icco,fp,offset)) != 0)
error ("%d, %s",rv,icco->e.m);
if (icco->header->cmmId == icmstr2tag("argl"))
icco->allowclutPoints256 = 1;
if (ntag_names > 0) {
int i;
for (i = 0; i < ntag_names; i++) {
icTagSignature sig = icmstr2tag(tag_names[i]);
/* Try and locate that particular tag */
if ((rv = icco->find_tag(icco,sig)) != 0 && rv != 1) {
warning ("icc->find_tag() can't find tag '%s' in file", icmtag2str(sig));
} else {
icmBase *ob;
if (rv == 1)
warning ("icc->find_tag() tag '%s' found but unknown type", tag_names[i]);
if ((ob = icco->read_tag_any(icco, sig)) == NULL) {
warning("Failed to read tag '%s': %d, %s",tag_names[i], icco->e.c,icco->e.m);
} else {
ob->dump(ob, op, verb-1);
}
}
}
} else {
icco->dump(icco, op, verb);
if (chid && icco->header->vers.majv >= 4) {
unsigned char id[16];
rv = icco->check_id(icco, id);
if (rv == 0) {
icmHeader *p = icco->header;
printf("Id check succeeds\n");
op->printf(op," ID is = %02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x%02x%02x\n",
p->id[0], p->id[1], p->id[2], p->id[3],
p->id[4], p->id[5], p->id[6], p->id[7],
p->id[8], p->id[9], p->id[10], p->id[11],
p->id[12], p->id[13], p->id[14], p->id[15]);
op->printf(op," ID should be = %02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x%02x%02x\n",
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
} else if (rv == 1) {
printf("Id can't be checked because it's not set\n");
op->printf(op," ID should be = %02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x%02x%02x\n",
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
} else if (rv == 2) {
icmHeader *p = icco->header;
printf("Id check fails:\n");
op->printf(op," ID is = %02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x%02x%02x\n",
p->id[0], p->id[1], p->id[2], p->id[3],
p->id[4], p->id[5], p->id[6], p->id[7],
p->id[8], p->id[9], p->id[10], p->id[11],
p->id[12], p->id[13], p->id[14], p->id[15]);
op->printf(op," ID should be = %02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x%02x%02x\n",
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
} else
warning("Failed to do ID check %d, %s",icco->e.c,icco->e.m);
}
}
offset += 128;
}
} while (found != 0);
icco->del(icco);
op->del(op);
fp->del(fp);
return 0;
}
/* Basic printf type error() and warning() routines */
void
error(char *fmt, ...)
{
va_list args;
fprintf(stderr,"iccdump: Error - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit (-1);
}
void
warning(char *fmt, ...)
{
va_list args;
fprintf(stderr,"iccdump: Warning - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}

532
Argyll_V3.5.0/icc/icclu.c Normal file
View File

@@ -0,0 +1,532 @@
/*
* International Color Consortium Format Library (icclib)
* Profile color lookup utility.
*
* Author: Graeme W. Gill
* Date: 1999/11/29
* Version: 2.15
*
* Copyright 1998 - 2012 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/* TTBD:
*
*/
/*
This file is intended to exercise the ability
of the icc library to translate colors through a profile.
It also serves as a concise example of how to do this.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "icc.h"
void error(char *fmt, ...), warning(char *fmt, ...);
void usage(void) {
fprintf(stderr,"Translate colors through an ICC profile, V%s\n",ICCLIB_VERSION_STR);
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: icclu [-v level] [-f func] [-i intent] [-o order] profile\n");
fprintf(stderr," -v level Verbosity level 0 - 2 (default = 1)\n");
fprintf(stderr," -f function f = forward, b = backwards, g = gamut, p = preview\n");
fprintf(stderr," -i intent p = perceptual, r = relative colorimetric,\n");
fprintf(stderr," s = saturation, a = absolute\n");
// fprintf(stderr," P = absolute perceptual, S = absolute saturation\n");
fprintf(stderr," -p oride x = XYZ_PCS, l = Lab_PCS, y = Yxy,\n");
fprintf(stderr," -o order n = normal (priority: lut > matrix > monochrome)\n");
fprintf(stderr," r = reverse (priority: monochrome > matrix > lut)\n");
fprintf(stderr," -s scale Scale device range 0.0 - scale rather than 0.0 - 1.0\n");
fprintf(stderr," -D verb Dump the Pe's of all conversions\n");
fprintf(stderr," -T Trace each step of conversions\n");
fprintf(stderr,"\n");
fprintf(stderr," The colors to be translated should be fed into standard input,\n");
fprintf(stderr," one input color per line, white space separated.\n");
fprintf(stderr," A line starting with a # will be ignored.\n");
fprintf(stderr," A line not starting with a number will terminate the program.\n");
exit(1);
}
int
main(int argc, char *argv[]) {
int fa,nfa; /* argument we're looking at */
icmErr e = { 0, { '\000'} };
static char prof_name[MAXNAMEL+1];
icmFile *fp;
icc *icco;
int verb = 1;
double scale = 0.0; /* Device value scale factor */
int rv = 0;
int repYxy = 0; /* Report Yxy */
char buf[200];
double oin[MAX_CHAN], in[MAX_CHAN], out[MAX_CHAN];
int dump = 0; /* Dump the conversions */
int trace = 0; /* Trace the conversions */
icmLuSpace *luo;
icmCSInfo ini, outi, pcsi; /* Type of input and output spaces */
icmCSInfo n_ini, n_outi, n_pcsi; /* Native type of input and output spaces */
icTagSignature srctag; /* Source tag of lookup */
icRenderingIntent rintent; /* Rendering intent */
icmLookupFunc lufunc; /* Lookup function */
icmLookupOrder luord; /* Lookup order */
icmPeOp luop; /* Dominant processing element operation */
int can_bwd; /* Whether lookup is invertable */
#define ins ini.sig /* Compatibility until code is switched over */
#define outs outi.sig
#define inn ini.nch
#define outn outi.nch
/* Lookup parameters */
icmLookupFunc func = icmFwd; /* Default */
icRenderingIntent intent = icmDefaultIntent; /* Default */
icColorSpaceSignature pcsor = icmSigDefaultData; /* Default */
icmLookupOrder order = icmLuOrdNorm; /* Default */
if (argc < 2)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
if (argv[fa][1] == '?')
usage();
/* Verbosity */
else if (argv[fa][1] == 'v') {
fa = nfa;
if (na == NULL)
verb = 2;
else {
if (na[0] == '0')
verb = 0;
else if (na[0] == '1')
verb = 1;
else if (na[0] == '2')
verb = 2;
else if (na[0] == '3')
verb = 3;
else
usage();
}
}
/* function */
else if (argv[fa][1] == 'f') {
fa = nfa;
if (na == NULL) usage();
switch (na[0]) {
case 'f':
case 'F':
func = icmFwd;
break;
case 'b':
case 'B':
func = icmBwd;
break;
case 'g':
case 'G':
func = icmGamut;
break;
case 'p':
case 'P':
func = icmPreview;
break;
default:
usage();
}
}
/* Intent */
else if (argv[fa][1] == 'i') {
fa = nfa;
if (na == NULL) usage();
switch (na[0]) {
case 'p':
intent = icPerceptual;
break;
case 'r':
intent = icRelativeColorimetric;
break;
case 's':
intent = icSaturation;
break;
case 'a':
intent = icAbsoluteColorimetric;
break;
/* Special function icclib intents */
case 'P':
intent = icmAbsolutePerceptual;
break;
case 'S':
intent = icmAbsoluteSaturation;
break;
default:
usage();
}
}
/* Search order */
else if (argv[fa][1] == 'o') {
fa = nfa;
if (na == NULL) usage();
switch (na[0]) {
case 'n':
order = icmLuOrdNorm;
break;
case 'r':
order = icmLuOrdRev;
break;
default:
usage();
}
}
/* PCS override */
else if (argv[fa][1] == 'p') {
fa = nfa;
if (na == NULL) usage();
switch (na[0]) {
case 'x':
case 'X':
pcsor = icSigXYZData;
repYxy = 0;
break;
case 'l':
case 'L':
pcsor = icSigLabData;
repYxy = 0;
break;
case 'y':
case 'Y':
pcsor = icSigXYZData;
repYxy = 1;
break;
default:
usage();
}
}
/* Device scale */
else if (argv[fa][1] == 's') {
fa = nfa;
if (na == NULL) usage();
scale = atof(na);
if (scale <= 0.0) usage();
}
else if (argv[fa][1] == 'D') {
fa = nfa;
if (na == NULL) usage();
dump = atoi(na);
if (dump <= 0.0) usage();
}
else if (argv[fa][1] == 'T') {
trace = 1;
}
else
usage();
} else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strncpy(prof_name,argv[fa++],MAXNAMEL); prof_name[MAXNAMEL] = '\000';
icm_err_clear_e(&e);
/* Open up the profile for reading */
if ((fp = new_icmFileStd_name(&e, prof_name,"r")) == NULL)
error ("Can't open file '%s', failed with 0x%x, '%s'",prof_name, e.c, e.m);
if ((icco = new_icc(&e)) == NULL)
error ("Creation of ICC object failed with 0x%x, '%s'", e.c, e.m);
if ((rv = icco->read(icco,fp,0)) != 0)
error ("%d, %s",rv,icco->e.m);
if (icco->header->cmmId == icmstr2tag("argl"))
icco->allowclutPoints256 = 1;
/* Dump profile header if verbose */
if (verb > 1) {
icmFile *op;
if ((op = new_icmFileStd_fp(&e, stdout)) == NULL)
error ("Can't open stdout, failed with 0x%x, '%s'", e.c, e.m);
icco->header->dump(icco->header, op, 1);
op->del(op);
}
/* Compute a TAC */
if (verb > 1) {
double tac;
double chmax[MAX_CHAN];
tac = icco->get_tac(icco, chmax, NULL, NULL);
if (tac <= -1.0)
printf("No TAC\n\n");
else
printf("TAC = %f, chan max = %s\n\n",tac,
icmPdv(icmCSSig2nchan(icco->header->colorSpace), chmax));
}
/* Get a conversion object */
if ((luo = (icmLuSpace *)icco->get_luobj(icco, func, intent, pcsor, order)) == NULL)
error ("%d, %s",icco->e.c, icco->e.m);
if (dump > 0) {
icmErr err = { 0 };
icmFile *op;
int verb = 1;
if ((op = new_icmFileStd_fp(&err, stdout)) == NULL) {
printf("Can't open stdout stream, failed with 0x%x, '%s'",err.c, err.m);
} else {
printf("\nOverall transform:\n");
luo->lookup->dump(luo->lookup, op, dump);
printf("\n3 Step transform:\n");
luo->input->dump(luo->input, op, dump);
luo->core3->dump(luo->core3, op, dump);
luo->output->dump(luo->output, op, dump);
printf("\n5 Step transform:\n");
luo->input_fmt->dump(luo->input_fmt, op, dump);
luo->input_pch->dump(luo->input_pch, op, dump);
luo->core5->dump(luo->core5, op, dump);
luo->output_pch->dump(luo->output_pch, op, dump);
luo->output_fmt->dump(luo->output_fmt, op, dump);
op->del(op);
}
}
if (trace) {
luo->lookup->trace = 1;
}
/* Get details of conversion (Arguments may be NULL if info not needed) */
luo->spaces(luo, &ini, &outi, &pcsi, &srctag, &rintent, &lufunc, &luord, &luop, &can_bwd);
luo->native_spaces(luo, &n_ini, &n_outi, &n_pcsi);
if (verb > 1) {
double pcs[3], white[3], black[3];
int asblk;
printf("Lookup details:\n");
printf(" ini = %s\n",icmCSInfo2str(&ini));
printf(" outi = %s\n",icmCSInfo2str(&outi));
printf(" pcsi = %s\n",icmCSInfo2str(&pcsi));
printf(" n_ini = %s\n",icmCSInfo2str(&n_ini));
printf(" n_outi = %s\n",icmCSInfo2str(&n_outi));
printf(" n_pcsi = %s\n",icmCSInfo2str(&n_pcsi));
printf(" src_tag = %s\n",icm2str(icmTagSig_alt, srctag));
printf(" intent = %s\n",icm2str(icmRenderingIntent, rintent));
printf(" lu func = %s\n",icm2str(icmTransformLookupFunc, lufunc));
printf(" lu order = %s\n",icm2str(icmTransformLookupOrder, luord));
printf(" lu attr.op = %s\n",icm2str(icmProcessingElementOp, luop));
printf(" can bwd ? = %s\n",can_bwd ? "yes" : "no");
asblk = luo->wh_bk_points(luo, pcs, white, black);
printf("Abs. XYZ PCS %s, white %s, black %s%s\n",
icmPdv(3, pcs), icmPdv(3, white), icmPdv(3, black), asblk ? " (assumed)" : "");
asblk = luo->lu_wh_bk_points(luo, pcs, white, black);
printf("Rel. XYZ PCS %s, white %s, black %s%s\n",
icmPdv(3, pcs), icmPdv(3, white), icmPdv(3, black), asblk ? " (assumed)" : "");
}
/* Show other derived attributes */
if (verb > 2) {
int maxres;
int chmax[MAX_CHAN];
maxres = luo->max_in_res(luo, chmax);
printf("Input curve maxres = %d, chan max = %s\n\n",maxres,
icmPiv(luo->lookup->inputChan, chmax));
maxres = luo->max_clut_res(luo, chmax);
printf("cLut maxres = %d, chan max = %s\n\n",maxres,
icmPiv(luo->lookup->inputChan, chmax));
maxres = luo->max_out_res(luo, chmax);
printf("Ouput curve maxres = %d, chan max = %s\n\n",maxres,
icmPiv(luo->lookup->outputChan, chmax));
}
if (repYxy) { /* report Yxy rather than XYZ */
if (ini.sig == icSigXYZData)
ini.sig = icSigYxyData;
if (outi.sig == icSigXYZData)
outi.sig = icSigYxyData;
}
/* Process colors to translate */
for (;;) {
int i,j;
char *bp, *nbp;
/* Init default input values */
for (i = 0; i < MAX_CHAN; i++) {
in[i] = oin[i] = 0.0;
}
/* Read in the next line */
if (fgets(buf, 200, stdin) == NULL)
break;
if (buf[0] == '#') {
if (verb > 0)
fprintf(stdout,"%s\n",buf);
continue;
}
/* For each input number */
for (nbp = buf, i = 0; i < MAX_CHAN; i++) {
bp = nbp;
in[i] = oin[i] = strtod(bp, &nbp);
if (nbp == bp)
break; /* Failed */
}
if (i == 0)
break;
/* If device data and scale */
if(scale > 0.0
&& ins != icSigXYZData
&& ins != icSigLabData
&& ins != icSigLuvData
&& ins != icSigYCbCrData
&& ins != icSigYxyData
&& ins != icSigHsvData
&& ins != icSigHlsData) {
for (i = 0; i < MAX_CHAN; i++) {
in[i] /= scale;
}
}
if (repYxy && ins == icSigYxyData) {
icmYxy2XYZ(in, in);
}
/* Do conversion */
if ((rv = luo->lookup_fwd(luo, out, in)) & icmPe_lurv_err)
error("%d, %s",icco->e.c,icco->e.m);
/* Output the results */
if (verb > 0) {
for (j = 0; j < inn; j++) {
if (j > 0)
fprintf(stdout," %f",oin[j]);
else
fprintf(stdout,"%f",oin[j]);
}
printf(" [%s] -> %s -> ", icm2str(icmColorSpaceSig, ins),
icm2str(icmTransformSourceTag, srctag));
}
if (repYxy && outs == icSigYxyData) {
icmXYZ2Yxy(out, out);
}
/* If device data and scale */
if(scale > 0.0
&& outs != icSigXYZData
&& outs != icSigLabData
&& outs != icSigLuvData
&& outs != icSigYCbCrData
&& outs != icSigYxyData
&& outs != icSigHsvData
&& outs != icSigHlsData) {
for (i = 0; i < MAX_CHAN; i++) {
out[i] *= scale;
}
}
for (j = 0; j < outn; j++) {
if (j > 0)
fprintf(stdout," %f",out[j]);
else
fprintf(stdout,"%f",out[j]);
}
if (verb > 0)
printf(" [%s]", icm2str(icmColorSpaceSig, outs));
if (rv != icmPe_lurv_OK)
printf(" (%s)",icmPe_lurv2str(rv));
fprintf(stdout,"\n");
}
/* Done with lookup object */
luo->del(luo);
icco->del(icco);
fp->del(fp);
return 0;
}
/* Basic printf type error() and warning() routines */
void
error(char *fmt, ...)
{
va_list args;
fprintf(stderr,"icclu: Error - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit (-1);
}
void
warning(char *fmt, ...)
{
va_list args;
fprintf(stderr,"icclu: Warning - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}

350
Argyll_V3.5.0/icc/iccrw.c Normal file
View File

@@ -0,0 +1,350 @@
/*
* International Color Consortium Format Library (icclib)
* Profile read then re-write skeleton utility.
*
* Author: Graeme W. Gill
* Date: 1999/11/29
* Version: 2.15
*
* Copyright 1997 - 2012 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/* TTBD:
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "icc.h"
/* Default is to do nothing... */
#undef DUMP_INCOMING
#undef TEST_VIDGAMTAG /* Add ColorSync 2.5 VideoCardGamma tag with linear table */
#undef TEST_SRGB_FIX /* Some test code */
#undef WP_PATCH /* Overwrite the white point */
#undef INVERT_GRAY /* Invert single TRC gray profile */
#undef MOD_A2B /* 0 */ /* Modify A2B RGB tables */
void error(char *fmt, ...), warning(char *fmt, ...);
void usage(void) {
fprintf(stderr,"Read and then re-write an ICC profile V%s\n",ICCLIB_VERSION_STR);
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: iccrw readprofile writeprofile\n");
exit(1);
}
int
main(int argc, char *argv[]) {
int fa,nfa; /* argument we're looking at */
icmErr e = { 0, { '\000'} };
static char in_name[MAXNAMEL+1];
static char out_name[MAXNAMEL+1];
icmFile *rd_fp, *wr_fp;
icc *icco;
int verb = 0;
int rv = 0;
if (argc < 3)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
if (argv[fa][1] == '?')
usage();
if (argv[fa][1] == 'v' || argv[fa][1] == 'V')
verb = 1;
/* No options */
usage();
} else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strncpy(in_name,argv[fa++],MAXNAMEL); in_name[MAXNAMEL] = '\000';
if (fa >= argc || argv[fa][0] == '-') usage();
strncpy(out_name,argv[fa++],MAXNAMEL); out_name[MAXNAMEL] = '\000';
icm_err_clear_e(&e);
/* Open up the profile for reading */
if ((rd_fp = new_icmFileStd_name(&e, in_name,"r")) == NULL)
error ("Can't open file '%s', failed with 0x%x, '%s'",in_name, e.c, e.m);
if ((icco = new_icc(&e)) == NULL)
error ("Creation of ICC object failed with 0x%x, '%s'", e.c, e.m);
/* Read header etc. */
if ((rv = icco->read(icco,rd_fp,0)) != 0)
error ("%d, %s",rv,icco->e.m);
/* Read every tag */
if (icco->read_all_tags(icco) != 0) {
error("Unable to read all tags: %d, %s",icco->e.c,icco->e.m);
}
rd_fp->del(rd_fp);
/* ======================================= */
/* Change profile in here. */
#ifdef DUMP_INCOMING
{
icmFile *op = new_icmFileStd_fp(NULL, stdout);
icco->dump(icco, op, 2);
op->del(op);
}
#endif
#ifdef NEVER
/* Add a generic discription */
{
icmMultiLocalizedUnicode *ro;
int i;
/* Try and read the tag from the file */
ro = (icmMultiLocalizedUnicode *)icco->read_tag(icco, icmMakeTag('d','s','c','m'));
if (ro == NULL)
error("Unable to read MLU tag");
/* Need to check that the cast is appropriate. */
if (ro->ttype != icSigMultiLocalizedUnicodeType)
error("rTRC is not icSigMultiLocalizedUnicodeType");
ro->rcount = 0;
ro->allocate(ro);
ro->desc = strdup("This is an extra description");
ro->count = strlen(ro->desc) + 1;
}
#endif
#ifdef TEST_SRGB_FIX /* Some test code */
/* Try deleting the black point tag */
{
if (icco->delete_tag(icco, icSigMediaBlackPointTag) != 0) {
error("Unable to delete blackpoint tag: %d, %s",icco->e.c,icco->e.m);
}
}
/* Fix up sRGB profile curve */
{
icmCurve *ro;
int i;
/* Try and read the tag from the file */
ro = (icmCurve *)icco->read_tag(icco, icSigRedTRCTag);
if (ro == NULL)
error("Unable to read rTRC");
/* Need to check that the cast is appropriate. */
if (ro->ttype != icSigCurveType)
error("rTRC is not CurveType");
for (i = 0; i < ro->size; i++) {
double vi, vo;
vi = i/(double)(ro->size-1);
if (vi < 0.04045) {
vo = vi/12.92;
} else {
vo = pow((0.055+vi)/1.055,2.4);
}
ro->data[i] = vo;
}
}
/* Show we modified this ICC file */
icco->header->cmmId = str2tag("argl"); /* CMM for profile - Argyll CMM */
#endif
#ifdef TEST_VIDGAMTAG
/* delete video card gamma tag (c/o Neil Okamoto) */
{
if (icco->find_tag(icco, icSigVideoCardGammaTag) == 0)
if (icco->delete_tag(icco, icSigVideoCardGammaTag) != 0)
error("Unable to delete videocardgamma tag: %d, %s",icco->e.c,icco->e.m);
}
/* Add a video card gamma table */
{
int c,i;
icmVideoCardGamma *wo;
wo = (icmVideoCardGamma *)icco->add_tag(icco, icSigVideoCardGammaTag, icSigVideoCardGammaType);
if (wo == NULL)
error ("Unable to add VideoCardGamma tag");
wo->tagType = icmVideoCardGammaTableType;
wo->u.table.channels = 3; /* rgb */
wo->u.table.entryCount = 256; /* full lut */
wo->u.table.entrySize = 1; /* byte */
wo->allocate((icmBase*)wo);
for (c = 0; c < 3; c++)
for (i = 0; i < 256; i++)
wo->u.table.data[c][i] = (1.0 - i/255.0);
}
/* Show we modified this ICC file */
icco->header->cmmId = str2tag("argl"); /* CMM for profile - Argyll CMM */
#endif
#ifdef WP_PATCH /* Overwrite the white point */
/* delete white point tag */
{
if (icco->find_tag(icco, icSigMediaWhitePointTag) == 0)
if (icco->delete_tag(icco, icSigMediaWhitePointTag) != 0)
error("Unable to delete white point tag tag: %d, %s",icco->e.c,icco->e.m);
}
/* Add a new white point tag */
{
double lab[3];
icmXYZArray *wo;
/* Note that tag types icSigXYZType and icSigXYZArrayType are identical */
if ((wo = (icmXYZArray *)icco->add_tag(
icco, icSigMediaWhitePointTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",icco->e.c, icco->e.m);
wo->size = 1;
wo->allocate((icmBase *)wo); /* Allocate space */
lab[0] = 79.8296;
lab[1] = -0.004042 + 0.842312;
lab[2] = 3.019928 + 0.810044;
icmLab2XYZ(&icmD50, lab, lab);
icmAry2XYZ(wo->data[0], lab);
}
/* Show we modified this ICC file */
icco->header->cmmId = str2tag("argl"); /* CMM for profile - Argyll CMM */
#endif
#ifdef INVERT_GRAY /* Invert single TRC gray profile */
{
icmCurve *ro;
int i;
/* Try and read the tag from the file */
ro = (icmCurve *)icco->read_tag(icco, icSigGrayTRCTag);
if (ro == NULL)
error("Unable to read GrayTRC");
/* Need to check that the cast is appropriate. */
if (ro->ttype != icSigCurveType)
error("GrayTRC is not CurveType");
/* Swap the curve entries from top to bottom */
for (i = 0; i < (ro->size/2); i++) {
double temp;
int ii = 255 - i;
temp = ro->data[ii];
ro->data[ii] = ro->data[i];
ro->data[i] = temp;
}
}
#endif
#ifdef MOD_A2B
{
icmLut *ro;
unsigned long size;
unsigned int i, j;
icTagSignature sig;
if (MOD_A2B == 0)
sig = icSigAToB0Tag;
else if (MOD_A2B == 1)
sig = icSigAToB1Tag;
else
sig = icSigAToB2Tag;
/* Try and read the tag from the file */
ro = (icmLut *)icco->read_tag(icco, sig);
if (ro == NULL)
error("Failed to read A2B tag");
/* Need to check that the cast is appropriate. */
if (ro->ttype != icSigLut16Type)
error("A2B is not 16 bitg");
/* Simply apply a gamma to the corresponding input curve */
for (i = 0; i < ro->inputChan; i++) { /* Input tables */
double val;
j = MOD_A2B;
val = ro->pe_ic[i]->data[j];
val = pow(val, 2.0);
ro->pe_ic[i]->data[j] = val;
}
}
#endif /* MOD_A2B */
/* ======================================= */
icm_err_clear_e(&e);
/* Open up the other profile for writing */
if ((wr_fp = new_icmFileStd_name(&e, out_name,"w")) == NULL)
error ("Can't open file '%s', failed with 0x%x, '%s'",out_name, e.c, e.m);
if ((rv = icco->write(icco,wr_fp,0)) != 0)
error ("Write file: %d, %s",rv,icco->e.m);
icco->del(icco);
wr_fp->del(wr_fp);
return 0;
}
/* ------------------------------------------------ */
/* Basic printf type error() and warning() routines */
void
error(char *fmt, ...)
{
va_list args;
fprintf(stderr,"iccrw: Error - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit (-1);
}
void
warning(char *fmt, ...)
{
va_list args;
fprintf(stderr,"iccrw: Warning - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}

632
Argyll_V3.5.0/icc/iccstd.c Normal file
View File

@@ -0,0 +1,632 @@
/*
* ICC library stdio and malloc utility classes.
*
* Author: Graeme W. Gill
* Date: 2002/10/24
* Version: 2.15
*
* Copyright 1997 - 2012 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*
* These are kept in a separate file to allow them to be
* selectively ommitted from the icc library.
*
*/
#ifndef COMBINED_STD
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#ifdef __sun
#include <unistd.h>
#endif
#include "icc.h"
#endif /* !COMBINED_STD */
#if defined(SEPARATE_STD) || defined(COMBINED_STD)
#ifdef _MSC_VER
#define fileno _fileno
#endif
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t)(-1))
#endif
static void Zmemory(void) { }
#define ZMARKER ((void *)Zmemory) /* Use address of function as zero memory marker */
/* -------------------------------------------------- */
/* Take a reference to the icmAlloc */
icmAlloc *icmAlloc_reference(
icmAlloc *pp
) {
pp->refcount++;
return pp;
}
/* -------------------------------------------------- */
/* Standard Heap allocator icmAlloc compatible class. */
/* Make the icclib malloc functions behave consistently, such as */
/* malloc(0) != NULL, realloc(NULL, size) and free(NULL) working, */
/* was well as providing recalloc() */
#ifndef ICC_DEBUG_MALLOC
static void icmAllocStd_free(
struct _icmAlloc *pp,
void *ptr
) {
if (ptr != NULL && ptr != ZMARKER) {
free(ptr);
}
}
static void *icmAllocStd_malloc(
struct _icmAlloc *pp,
size_t size
) {
if (size == 0) /* Some malloc's return NULL for zero size */
return ZMARKER;
return malloc(size);
}
static void *icmAllocStd_realloc(
struct _icmAlloc *pp,
void *ptr,
size_t size
) {
if (size == 0) { /* Some malloc's return NULL for zero size */
icmAllocStd_free(pp, ptr);
return ZMARKER;
}
if (ptr == ZMARKER)
ptr = NULL;
if (ptr == NULL) /* Some realloc's barf on reallocing NULL */
return malloc(size);
return realloc(ptr, size);
}
static void *icmAllocStd_calloc(
struct _icmAlloc *pp,
size_t num,
size_t size
) {
int ind = 0;
size_t tot = sati_mul(&ind, num, size);
if (ind != 0)
return NULL; /* Overflow */
if (tot == 0) /* Some malloc's return NULL for zero size */
return ZMARKER;
return calloc(num, size);
}
static void *icmAllocStd_recalloc(
struct _icmAlloc *pp,
void *ptr,
size_t cnum, /* Current number and size */
size_t csize,
size_t nnum, /* New number and size */
size_t nsize
) {
int ind = 0;
size_t ctot, ntot;
if (ptr == NULL)
return icmAllocStd_calloc(pp, nnum, nsize);
ntot = sati_mul(&ind, nnum, nsize);
if (ind != 0)
return NULL; /* Overflow */
ctot = sati_mul(&ind, cnum, csize);
if (ind != 0)
return NULL; /* Overflow */
ptr = icmAllocStd_realloc(pp, ptr, ntot);
if (ptr != NULL && ptr != ZMARKER && ntot > ctot)
memset((char *)ptr + ctot, 0, ntot - ctot); /* Clear the new region */
return ptr;
}
/* we're done with the AllocStd object */
static void icmAllocStd_delete(
icmAlloc *pp
) {
if (pp == NULL || --pp->refcount > 0)
return;
{
icmAllocStd *p = (icmAllocStd *)pp;
free(p);
}
}
/* Create icmAllocStd */
/* Note that this will fail if e has an error already set */
icmAlloc *new_icmAllocStd(icmErr *e) {
icmAllocStd *p;
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
if ((p = (icmAllocStd *) calloc(1,sizeof(icmAllocStd))) == NULL) {
icm_err_e(e, ICM_ERR_MALLOC, "Allocating Standard Allocator object failed");
return NULL;
}
p->refcount = 1;
p->malloc = icmAllocStd_malloc;
p->calloc = icmAllocStd_calloc;
p->realloc = icmAllocStd_realloc;
p->recalloc = icmAllocStd_recalloc;
p->free = icmAllocStd_free;
p->reference = icmAlloc_reference;
p->del = icmAllocStd_delete;
return (icmAlloc *)p;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - */
#else /* ICC_DEBUG_MALLOC */
/* Make sure that inline malloc #defines are turned off for this file */
#undef was_debug_malloc
#ifdef malloc
#undef malloc
#undef calloc
#undef realloc
#undef recalloc
#undef free
#define was_debug_malloc
#endif /* dmalloc */
static void *icmAllocStd_dmalloc(
struct _icmAlloc *pp,
size_t size,
char *name,
int line
) {
if (size == 0) /* Some malloc's return NULL for zero size */
return ZMARKER;
return malloc(size);
}
static void *icmAllocStd_drealloc(
struct _icmAlloc *pp,
void *ptr,
size_t size,
char *name,
int line
) {
if (size == 0) { /* Some malloc's return NULL for zero size */
icmAllocStd_dfree(pp, ptr, name, line);
return ZMARKER;
}
if (ptr == NULL) /* Some realloc's barf on reallocing NULL */
return malloc(size);
return realloc(ptr, size);
}
static void *icmAllocStd_dcalloc(
struct _icmAlloc *pp,
size_t num,
size_t size,
char *name,
int line
) {
int ind = 0;
size_t tot = sati_mul(&ind, num, size);
if (ind != 0)
return NULL; /* Overflow */
if (tot == 0) /* Some malloc's return NULL for zero size */
return ZMARKER;
return calloc(num, size);
}
static void *icmAllocStd_drecalloc(
struct _icmAlloc *pp,
void *ptr,
size_t cnum, /* Current number and size */
size_t csize,
size_t nnum, /* New number and size */
size_t nsize,
char *name,
int line
) {
int ind = 0;
size_t ctot, ntot;
if (ptr == NULL)
return icmAllocStd_dcalloc(pp, nnum, nsize, name, line);
ntot = sati_mul(&ind, nnum, nsize);
if (ind != 0)
return NULL; /* Overflow */
ctot = sati_mul(&ind, cnum, csize);
if (ind != 0)
return NULL; /* Overflow */
ptr = icmAllocStd_realloc(pp, ptr, ntot, name, line);
if (ptr != NULL && ptr != ZMARKER && ntot > ctot)
memset((char *)ptr + ctot, 0, ntot - ctot); /* Clear the new region */
return ptr;
}
static void icmAllocStd_dfree(
struct _icmAlloc *pp,
void *ptr,
char *name,
int line
) {
if (ptr != NULL && ptr != ZMARKER)
free(ptr);
}
/* we're done with the AllocStd object */
static void icmAllocStd_delete(
icmAlloc *pp
) {
if (p == NULL || --p->refcount > 0)
return;
{
icmAllocStd *p = (icmAllocStd *)pp;
free(p);
}
}
/* Create icmAllocStd */
icmAlloc *new_icmAllocStd(icmErr *e) {
icmAllocStd *p;
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
if ((p = (icmAllocStd *) calloc(1,sizeof(icmAllocStd))) == NULL) {
icm_err_e(e, ICM_ERR_MALLOC, "Allocating Standard Allocator object failed");
return NULL;
}
p->refcount = 1;
p->dmalloc = icmAllocStd_dmalloc;
p->drealloc = icmAllocStd_drealloc;
p->dcalloc = icmAllocStd_dcalloc;
p->drecalloc = icmAllocStd_drecalloc;
p->dfree = icmAllocStd_dfree;
p->reference = icmAlloc_reference;
p->del = icmAllocStd_delete;
return (icmAlloc *)p;
}
#ifdef was_debug_malloc
/* Re-enable debug malloc #defines */
#define malloc( p, size ) dmalloc( p, size, __FILE__, __LINE__ )
#define calloc( p, num, size ) dcalloc( p, num, size, __FILE__, __LINE__ )
#define realloc( p, ptr, size ) drealloc( p, ptr, size, __FILE__, __LINE__ )
#define recalloc( p, ptr, cnum, csize, nnum, nsize ) drecalloc( p, ptr, cnum, csize, nnum, nsize, __FILE__, __LINE__ )
#define free( p, ptr ) dfree( p, ptr , __FILE__, __LINE__ )
#undef was_debug_malloc
#endif /* was_debug_malloc */
#endif /* ICC_DEBUG_MALLOC */
/* ------------------------------------------------- */
/* Standard Stream file I/O icmFile compatible class */
/* Get the size of the file (Only valid for reading file). */
static size_t icmFileStd_get_size(icmFile *pp) {
icmFileStd *p = (icmFileStd *)pp;
return p->size;
}
/* Set current position to offset. Return 0 on success, nz on failure. */
static int icmFileStd_seek(
icmFile *pp,
unsigned int offset
) {
icmFileStd *p = (icmFileStd *)pp;
return fseek(p->fp, offset, SEEK_SET);
}
/* Read count items of size length. Return number of items successfully read. */
static size_t icmFileStd_read(
icmFile *pp,
void *buffer,
size_t size,
size_t count
) {
icmFileStd *p = (icmFileStd *)pp;
return fread(buffer, size, count, p->fp);
}
/* write count items of size length. Return number of items successfully written. */
static size_t icmFileStd_write(
icmFile *pp,
void *buffer,
size_t size,
size_t count
) {
icmFileStd *p = (icmFileStd *)pp;
return fwrite(buffer, size, count, p->fp);
}
/* do a printf */
static int icmFileStd_printf(
icmFile *pp,
const char *format,
...
) {
int rv;
va_list args;
icmFileStd *p = (icmFileStd *)pp;
va_start(args, format);
rv = vfprintf(p->fp, format, args);
va_end(args);
return rv;
}
/* flush all write data out to secondary storage. Return nz on failure. */
static int icmFileStd_flush(
icmFile *pp
) {
icmFileStd *p = (icmFileStd *)pp;
return fflush(p->fp);
}
/* Return the memory buffer. Error if not icmFileMem */
static int icmFileStd_get_buf(
icmFile *pp,
unsigned char **buf,
size_t *len
) {
return 1;
}
/* Take a reference to the icmFileStd */
static icmFile *icmFileStd_reference(
icmFile *pp
) {
pp->refcount++;
return pp;
}
/* we're done with the file object, return nz on failure */
static int icmFileStd_delete(
icmFile *pp
) {
if (pp == NULL || --pp->refcount > 0)
return 0;
{
int rv = 0;
icmFileStd *p = (icmFileStd *)pp;
icmAlloc *al = p->al;
if (p->doclose != 0) {
if (fclose(p->fp) != 0)
rv = 2;
}
al->free(al, p); /* Free this object */
al->del(al); /* Free allocator if this is the last reference */
return rv;
}
}
/* Create icmFile given a (binary) FILE* */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileStd_fp(
icmErr *e, /* Sticky return error, may be NULL */
FILE *fp
) {
return new_icmFileStd_fp_a(e, fp, NULL);
}
/* Create icmFile given a (binary) FILE* and allocator */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileStd_fp_a(
icmErr *e, /* Sticky returned error, may be NULL */
FILE *fp,
icmAlloc *al /* heap allocator, NULL for default */
) {
icmFileStd *p = NULL;
struct stat sbuf = { 0 };
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
if (al == NULL) { /* None provided, create default */
if ((al = new_icmAllocStd(e)) == NULL)
return NULL;
} else {
al = al->reference(al);
}
if ((p = (icmFileStd *) al->calloc(al, 1, sizeof(icmFileStd))) == NULL) {
al->del(al);
icm_err_e(e, ICM_ERR_MALLOC, "Allocating Standard File object failed");
return NULL;
}
p->refcount = 1;
p->al = al;
p->get_size = icmFileStd_get_size;
p->seek = icmFileStd_seek;
p->read = icmFileStd_read;
p->write = icmFileStd_write;
p->printf = icmFileStd_printf;
p->flush = icmFileStd_flush;
p->get_buf = icmFileStd_get_buf;
p->reference = icmFileStd_reference;
p->del = icmFileStd_delete;
p->fp = fp;
p->doclose = 0;
if (fstat(fileno(fp), &sbuf) == 0) {
p->size = sbuf.st_size;
} else {
p->size = 0; /* Hmm. */
}
return (icmFile *)p;
}
/* Create icmFile given a file name */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileStd_name(
icmErr *e, /* sticky return error, may be NULL */
char *name,
char *mode
) {
return new_icmFileStd_name_a(e, name, mode, NULL);
}
/* Create given a file name and allocator */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileStd_name_a(
icmErr *e, /* Sticky return error, may be NULL */
char *name,
char *mode,
icmAlloc *al /* heap allocator, NULL for default */
) {
FILE *fp;
icmFile *p;
char nmode[50];
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
strcpy(nmode, mode);
#if !defined(O_CREAT) && !defined(_O_CREAT)
# error "Need to #include fcntl.h!"
#endif
#if defined(O_BINARY) || defined(_O_BINARY)
strcat(nmode, "b");
#endif
if ((fp = fopen(name,nmode)) == NULL) {
icm_err_e(e, ICM_ERR_FILE_OPEN, "Opening file '%s' failed",name);
return NULL;
}
p = new_icmFileStd_fp_a(e, fp, al);
if (p != NULL) {
icmFileStd *pp = (icmFileStd *)p;
pp->doclose = 1;
}
return p;
}
/* ------------------------------------------------- */
/* Create a memory image file access class with the std allocator */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileMem(
icmErr *e, /* Sticky return error, may be NULL */
void *base, /* Pointer to base of memory buffer */
size_t length /* Number of bytes in buffer */
) {
icmFile *p;
icmAlloc *al; /* memory allocator */
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
if ((al = new_icmAllocStd(e)) == NULL)
return NULL;
if ((p = new_icmFileMem_a(e, base, length, al)) == NULL) {
al->del(al);
return NULL;
}
al->del(al); /* icmFile will have taken a reference */
return p;
}
/* Create a memory image file access class with the std allocator */
/* and delete buffer when icmFile is deleted. */
/* Note that this will fail if e has an error already set */
icmFile *new_icmFileMem_d(
icmErr *e, /* Sticky return error, may be NULL */
void *base, /* Pointer to base of memory buffer */
size_t length /* Number of bytes in buffer */
) {
icmFile *fp;
if ((fp = new_icmFileMem(e, base, length)) != NULL) {
((icmFileMem *)fp)->del_buf = 1;
}
return fp;
}
/* ------------------------------------------------- */
/* Create an icc with the std allocator */
/* Note that this will fail if e has an error already set */
icc *new_icc(icmErr *e) {
icc *p;
icmAlloc *al; /* memory allocator */
if (e != NULL && e->c != ICM_ERR_OK)
return NULL; /* Pre-existing error */
if ((al = new_icmAllocStd(e)) == NULL)
return NULL;
if ((p = new_icc_a(e, al)) == NULL) {
al->del(al);
return NULL;
}
al->del(al); /* new_icc_a will have taken a reference */
return p;
}
/* ------------------------------------------------- */
/* Create an icmMD5 with the std allocator */
/* Note that this will fail if e has an error already set */
icmMD5 *new_icmMD5(icmErr *e) {
icmMD5 *p;
icmAlloc *al; /* memory allocator */
if ((al = new_icmAllocStd(e)) == NULL)
return NULL;
if ((p = new_icmMD5_a(e, al)) == NULL) {
al->del(al);
return NULL;
}
al->del(al); /* new_icmMD5_a will have taken a reference */
return p;
}
#endif /* defined(SEPARATE_STD) || defined(COMBINED_STD) */

3729
Argyll_V3.5.0/icc/icctest.c Normal file

File diff suppressed because it is too large Load Diff

BIN
Argyll_V3.5.0/icc/lab2lab.icm Executable file

Binary file not shown.

316
Argyll_V3.5.0/icc/log.txt Executable file
View File

@@ -0,0 +1,316 @@
Change History: (See ArgyllCMS log.txt too)
3.0.0
Added new combined icmLu object with API that differs from earlier versions.
Changed lu->spaces() arguments to compact each colorspace information,
and to eliminate get_ranges() and get_lutranges() methods.
Other lu->spaces() arguments also change.
Renamed lutspaces() -> native_spaces()
Changed lu transform method names:
1 step:
lookup -> lookup_fwd
3 step:
lookup_in -> input_fwd
lookup_core -> core3_fwd
lookup_out -> output_fwd
lookup_inv_in -> input_bwd
lu2mono:
1 step:
fwd_lookup -> lookup_fwd
bwd_lookup -> lookup_bwd
5 step:
fwd_curve -> (input_fmt_fwd) + input_pch_fwd
fwd_map -> core5_fwd
fwd_abs -> (output_pch_fwd) + output_fmt_fwd
bwd_abs -> output_fmt_bwd + (output_pch_bwd)
bwd_map -> core5_bwd
bwd_curve -> input_pch_bwd + (input_fmt_bwd);
lu2matrix:
1 step:
fwd_lookup -> lookup_fwd
bwd_lookup -> lookup_bwd
5 step:
fwd_curve -> (input_fmt_fwd) + input_pch_fwd
fwd_matrix -> core5_fwd
fwd_abs -> (output_pch_fwd) + output_fmt_fwd
bwd_abs -> output_fmt_bwd = (output_pch_bwd)
bwd_matrix -> core5_bwd
bwd_curve -> input_pch_bwd + (input_fmt_bwd);
lu2lut:
5 step:
in_abs -> input_fmt_fwd
matrix -> XXXXXXXXXXXXX none. Combined with input & clut
input -> input_pch_fwd
clut -> core5_fwd
output -> output_pch_fwd
out_abs -> output_fmt_fwd
inv_out_abs -> output_fmt_bwd
inv_output -> output_pch_bwd
(clut) (clut not invertable)
inv_input -> input_pch_bwd
inv_matrix -> XXXXXXXXXXXXX none. Combined with clut & input
inv_in_abs -> input_fmt_bwd
Split out less icc specific source code into icc_util.[ch]
Add new TagType parsing code (icmSn*)
Old parsing code is labeled LEGACY
Switch header and main profile code to use new parsing code.
Changed implementation ICC version numbers to use icmTV
Added controls to format compatibility checking and warning (icmCompatFlags).
Added warning callback function to handle warnings.
Changed icclib API to use UTF-8 to communicate Unicode text.
icmTextDescription now uses *uc8Desc for string and uc8Count for its length.
Remove need to cast of tagtype object to icmBase
when invoking icmBase methods:
i.e. get_size(), read(), write(), del(), dump(), allocate()
Most tagtype members called "size" have been renamed "count".
icmProfileSequenceDesc struct now has pointer to TextDescriptions rather than
being embeded, and these have been renamed: device -> mfgDesc, model -> modelDesc.
icmData now uses icBinaryData and icAsciiData as type value.
icmText elment data renamed to desc.
icmColorantTable now uses allocated name strings.
icmMeasurement flare is now icMeasurementFlare enum.
icmScreening flags is now icScreening screeningFlags
NamedColor prefix/suffix/root strings need to have count set and allocate().
icmVideoCardGamma now uses double array to store data, rather than
being tag details dependent. tagType is now icVideoCardGammaFormat.
Converted red/green/blue gamma/min/max to arrays.
icmCurve icmCurveStyel flag -> icmCurveType ctype
Changed to use icmErr error to hold error code & message.
icm.err[] -> icc.e.m[]
icm.errc -> icc.e.c
Some functions now have a new first argument of *icmErr.
Note that it is treated as "sticky" so that several
functions can be called before checking for errors.
new_icmAllocStd()
new_icmFileStd_name()
new_icmFileStd_fp()
new_icmFileStd_name_a()
new_icmFileStd_fp_a()
new_icmFileMem_a()
new_icmFileMem_ad()
new_icmFileMem()
new_icmFileMem_d()
new_icmMD5_a()
new_icmMD5()
new_icc_a()
new_icc()
Renamed str2tag() -> icmstr2tag()
Renamed icmLuAlg -> icmTransformLookupAlgorithm
2.21
Automatically repair icmTextDescription strings have an allocation that is longer
than their size.
2.20
Add better cross compatibility with non-Argyll ICC profiles:
+ Use "wrong Von Kries" media white point adapation for non-Argyll non-display profile
+ Optionally create "wrong Von Kries" media white point adapation profiles
using the "ARGYLL_CREATE_WRONG_VON_KRIES_OUTPUT_CLASS_REL_WP" env. variable,
while maintaining ArgyllCMS compatibility using the 'arts' tag.
+ Implement proper absolute colorimetric intent for ICCV2 Display profiles
that use the ICCV4 style of have a media white of D50 and storing the
media chromatic trasnform in the 'chad' tag.
+ Optionally create such ICCV4 style V2 Display profiles by using the
"ARGYLL_CREATE_DISPLAY_PROFILE_WITH_CHAD" env. variable.
2.16
Clean up cLUT read code to make sanity checking
more explicit and remove redundant code.
Added special mode that interprets cLUT res of 0 as 256
for MadVR testing.
Change icc->read_tag() to only succeed if the tag type is
known, since the standard expectation of a non NULL
return type is that it is of a known type. Added new
method icc->read_tag_any() which will return a
icmSigUnknownType if the tag type is unknown.
2.14
Fix potential array bounds violation in icc/icc.c for malformed
cLUT profiles with zero input channels.
2.10
Added protection against crafted file integer overflows.
Many minor additions to support ArgyllCMS.
Further add V4 compatibility, with changes to PCS encoding.
2.06
Added MD5 checksum code for profile ID support.
2.05
Version in Argyll V0.51 release.
Started adding support for ICC V4. Not enabled yet.
Expanded internal/effective colorspace/ranges support
to be uniform between all the lookup types.
2.04
Fixed minor casting nits picked up by some compilers
(thanks to Keith Trummel).
Make intent selection for Matrix profiles and Gamut tables
more forgiving if not ICM_STRICT.
2.03
Added simple extention when dumping binary data tag to
dump ASCII as well if verb >= 4.
Added Makefile support for compiling under MAC OSX.
Added access to primitive read and write functions, so custom tag
data can be marshalled using standard encodings.
Expanded ICM_STRICT to encompass bad DateTime information in the header,
and also disable required tag checking on reading or lookups.
Changed default intent for Output profiles to perceptual from
colorimetric, since this would usually be expected.
Added workaround for faulty Kodak RGB matrix profiles, that
have their primary XYZ coordinates scaled to 100.0 rather than
1.0. This is enabled if ICM_STRICT is not defined.
Replaced Lab<->XYZ functions with simpler versions.
Expand icmFile implimentation to handle icmAlloc
Do check for header Magic number first.
Add convenience function that creates an RGB to XYZ transform
matrix from the device primaries and the white point.
Separated stdio versions of file and alloc to allow
compile without these.
Non-standard (ie. Apple) 5,6,7 & 8 channel color signatures
weren't being handled properly thruout the library.
2.02
Merged rename of [u]int64 to icm[Ui][I]nt64 (to work around
AIX 5.1L portability bug) from Raph Levien.
Fixed stray , in icmLookupOrder structure definition (from Dan Coby)
2.01
Change TextDescription code to not barf if #undef ICM_STRICT and
Apple scriptcode not padded to 67 bytes.
Add get_ranges() method to all Lu types, not just LuLut.
Fix bug in PCS override logic that was causing
reverse conversions to apply the wrong conversion.
Added Delta E convenience functions icmLabDE() and
icmCIE94() etc.
Merged Raph Levien's cleanups, to quiet gcc warnings.
Merged another couple of warning cleanups from Jouk Jansen.
2.00
Change absolute conversion to be white point only, and use
Bradford transform by default. (ie. we are now ignoring the
comment in section 6.4.22 of the 1998 spec. about the
media black point being used for absolute colorimetry,
ignoring the recommendation on page 118 in section E.5,
and are taking up the recommendation on page 124 in section
E.16 that a more sophisticated chromatic adaptation model be used.)
This is for better compatibility with other CMM's, and to
improve the results when using simple links between
profiles with non-D50 white points. Standard profiles
like sRGB will also be more accurate when interpreted
with absolute colorimetric intent.
This will cause some slight incompatibilty with previous
versions of icclib.
Added ColorSync 2.5 specific VideoCardGamma tag support
(from Neil Okamoto)
1.31
Added file I/O class to allow substitution of alternative ICC profile
file access. Provide standard file class instance, and memory image
instance of file I/O class as default and example.
Added an optional new_icc_a() object creator, that takes a memory
allocator class instance. This allows an alternate memory heap to
be used with the icc class.
Renamed object free() methods to del() for more consistency with new().
1.30
Added workaround for reading some Adobe profiles with confused header DateTime.
Enhanced tag allocate() methods so that they can resize allocations.
Enhanced icmLut_set_tables() to access grid points in a cache friendly order.
Fixed bug in check_icc_legal() that caused bogus errors, removed
uneccessary static declarations in icc.h, and fixed a bug in
icmTable_lookup_bwd() that effected both accuracy and speed. (Thanks to Andrei Frolov)
Removed icmAbsoluteColorimetricXYZ intent, and replaced it with
a PCS override capability. This adds a new parameter to get_luobj()
Added Lab translations of some XYZ "dump" strings.
Fix memory leak after failed tag read + rename_tag function
+ shared library support changes. (Thanks to Carles Llopis).
Changed all the public 2str utility routines to a single function
that can be used to interpret an enumeration or tag in a human
readable form.
1.23
Fixed important bug in Lut read/write. The matrix values had their
rows and columns switched. Not many profiles exercise this code.
Thanks to David Gillman for discovering this problem.
Fixup compiler complains about illegal enum values for icmCurveStyle,
and icmDataStyle. Malloc memory icmLut_lookup_clut_nl for gw[], so that
it is more friendly to systems with a limited stack. (Thanks to Dave White)
1.22 99/11/11 Snapshot of current code.
Added more hooks to support inherited implementation of
color conversion, used in Argyll to support reversing
multi-dimentional table lookups.
Cleaned up color conversion code to make it easier to follow.
Adding simplex interpolation for non-Lab style input space interpolation.
Fix Sun misalignment and realloc problems (Thanks to Allan N. Hessenflow)
Fixed endian problem with Unicode on read and write.
Expanded icmTextDescription_dump() to do hex dump of Unicode and ScriptCode.
Changed over to ICC.1:1998-09 .h file.
Started implementing ICC.1:1998-09, but not complete yet!
1.21 99/2/14
After re-reading Michael Bourgoin's 1998 SIGGRAPH notes,
I have consolidated the Lut input index, and table value encodings.
The default set_tables() scaling has been adjusted appropriately
for this correction of Lab encoding.
Trying to create an 8 bit XYZ Lut will now fail if icclib helper
functions are used to create it.
1.20 99/2/7
Added profile color lookup functon.
Added set_tables() support.
Various bug fixes and enhancements.

3976
Argyll_V3.5.0/icc/lutest.c Normal file

File diff suppressed because it is too large Load Diff

332
Argyll_V3.5.0/icc/mcheck.c Normal file
View File

@@ -0,0 +1,332 @@
/*
* International Color Consortium Format Library (icclib)
* Check the device chanel to PCS monotonicity.
*
* Author: Graeme W. Gill
* Date: 2000/12/11
* Version: 2.15
*
* Copyright 2000 - 2012 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*/
/* TTBD:
*
* Make general device input, not just CMYK
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "vrml.h"
#include "icc.h"
void error(char *fmt, ...), warning(char *fmt, ...);
void usage(void) {
fprintf(stderr,"Check device to PCS monotonicity of a CMYK ICC file, V%s\n",ICCLIB_VERSION_STR);
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: mcheck [-v] [-w] infile\n");
fprintf(stderr," -v verbose\n");
fprintf(stderr," -c Check just Cyan monotonicity\n");
fprintf(stderr," -m Check just Magenta monotonicity\n");
fprintf(stderr," -y Check just Yellow monotonicity\n");
fprintf(stderr," -k Check just Black monotonicity\n");
fprintf(stderr," -w create %s visualisation\n",vrml_format());
fprintf(stderr," -x use %s axes\n",vrml_format());
exit(1);
}
#define MGR 50 /* Maximum grid resolution handled */
int
main(
int argc,
char *argv[]
) {
int fa,nfa; /* argument we're looking at */
icmErr e = { 0, { '\000'} };
int verb = 0;
int cchan = -1; /* default all */
int dovrml = 0;
int doaxes = 0;
static char in_name[MAXNAMEL+1];
static char out_name[MAXNAMEL+1], *xl;
icmFile *rd_fp;
icc *wr_icco, *rd_icco; /* Keep object separate */
int rv = 0;
/* Check variables */
icmLuBase *luo;
icmLuLut *luluto; /* Lookup xLut type object */
int gres; /* Grid resolution */
icColorSpaceSignature ins, outs; /* Type of input and output spaces */
int inn; /* Number of input chanels */
icmLuAlgType alg;
vrml *wrl;
int dx[4]; /* Device index mapping */
int chan, cs, ce;
if (argc < 2)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
/* Verbosity */
if (argv[fa][1] == 'v' || argv[fa][1] == 'V') {
verb = 1;
}
/* VRML/X3D */
else if (argv[fa][1] == 'w' || argv[fa][1] == 'W') {
dovrml = 1;
}
/* Cyan */
else if (argv[fa][1] == 'c' || argv[fa][1] == 'C') {
cchan = 0;
}
/* Magenta */
else if (argv[fa][1] == 'm' || argv[fa][1] == 'M') {
cchan = 1;
}
/* Yellow */
else if (argv[fa][1] == 'y' || argv[fa][1] == 'Y') {
cchan = 2;
}
/* Black */
else if (argv[fa][1] == 'k' || argv[fa][1] == 'K') {
cchan = 3;
}
else if (argv[fa][1] == 'x') {
doaxes = 1;
}
else if (argv[fa][1] == '?')
usage();
else
usage();
}
else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strncpy(in_name,argv[fa++],MAXNAMEL); in_name[MAXNAMEL] = '\000';
strcpy(out_name, in_name);
if ((xl = strrchr(out_name, '.')) == NULL) /* Figure where extention is */
xl = out_name + strlen(out_name);
xl[0] = '\000'; /* Remove extension */
icm_err_clear_e(&e);
/* Open up the file for reading */
if ((rd_fp = new_icmFileStd_name(&e, in_name,"r")) == NULL)
error ("Read: Can't open file '%s', failed with 0x%x, '%s'",in_name, e.c, e.m);
if ((rd_icco = new_icc(&e)) == NULL)
error ("Read: Creation of ICC object failed with 0x%x, '%s'", e.c, e.m);
/* Read the header and tag list */
if ((rv = rd_icco->read(rd_icco,rd_fp,0)) != 0)
error ("Read: %d, %s",rv,rd_icco->e.m);
/* Get a Device to PCS conversion object */
if ((luo = rd_icco->get_luobj(rd_icco, icmFwd, icRelativeColorimetric, icSigLabData, icmLuOrdNorm)) == NULL) {
if ((luo = rd_icco->get_luobj(rd_icco, icmFwd, icmDefaultIntent, icSigLabData, icmLuOrdNorm)) == NULL)
error ("%d, %s",rd_icco->e.c, rd_icco->e.m);
}
/* Get details of conversion */
luo->spaces(luo, &ins, &inn, &outs, NULL, &alg, NULL, NULL, NULL, NULL);
if (alg != icmLutType) {
error("Expecting Lut based profile");
}
if (ins != icSigCmykData) {
error("Expecting CMYK device");
}
if (outs != icSigLabData) {
error("Expecting Lab PCS");
}
luluto = (icmLuLut *)luo; /* Lookup xLut type object */
gres = luluto->lut->clutPoints;
if (gres > MGR) {
error("Can't handle grid resolution greater than %d\n",MGR);
}
if (dovrml) {
wrl = new_vrml(out_name, doaxes, vrml_lab);
if (wrl == NULL)
error("new_vrml for '%s%s' failed",out_name,vrml_ext());
wrl->start_line_set(wrl, 0);
}
/* For all the device chanels chosen */
if (cchan < 0) {
cs = 0;
ce = inn;
} else {
cs = cchan;
ce = cs + 1;
}
for (chan = cs; chan < ce; chan++) {
/* Check the monotonicity of the output for a given device input */
int co[4];
if (chan == 0) {
dx[0] = 1;
dx[1] = 2;
dx[2] = 3;
dx[3] = 0; /* Cyan is variable */
} else if (chan == 1) {
dx[0] = 0;
dx[1] = 2;
dx[2] = 3;
dx[3] = 1; /* Magenta is variable */
} else if (chan == 2) {
dx[0] = 0;
dx[1] = 1;
dx[2] = 3;
dx[3] = 2; /* Yellow is variable */
} else if (chan == 3) {
dx[0] = 0;
dx[1] = 1;
dx[2] = 2;
dx[3] = 3; /* Black is variable */
}
/* Itterate throught the CMY clut grid points */
for (co[0] = 0; co[0] < gres; co[0]++) {
for (co[1] = 0; co[1] < gres; co[1]++) {
for (co[2] = 0; co[2] < gres; co[2]++) {
int j, k, ck, nm;
double dev[MGR][4];
double pcs[MGR][3];
double apcs[3], ss;
/* Run up the variable axis */
for (ck = 0; ck < gres; ck++) {
dev[ck][dx[0]] = co[0]/(gres-1.0);
dev[ck][dx[1]] = co[1]/(gres-1.0);
dev[ck][dx[2]] = co[2]/(gres-1.0);
dev[ck][dx[3]] = ck/(gres-1.0);
/* Device to PCS */
if ((rv = luluto->clut(luluto, pcs[ck], dev[ck])) > 1)
error ("%d, %s",rd_icco->e.c,rd_icco->e.m);
// if (dovrml)
// wrl->add_vertex(wrl, 0, pcs[ck]);
}
/* Compute average vector direction */
for (ss = 0.0, k = 0; k < 3; k++) {
double tt;
tt = pcs[gres-1][k] - pcs[0][k];
ss += tt * tt;
apcs[k] = tt;
}
for (k = 0; k < 3; k++)
apcs[k] /= ss;
/* Now compute the dot product for each vector, */
/* and check for reversals. */
j = 0;
//printf("Checking CMYK %f %f %f %f Lab %f %f %f\n",
// dev[j][0], dev[j][1], dev[j][2], dev[j][3],
// pcs[j][0], pcs[j][1], pcs[j][2]);
for (nm = 0, j = 1; j < gres; j++) {
for (ss = 0.0, k = 0; k < 3; k++) /* Dot product */
ss += (pcs[j][k] - pcs[j-1][k]) * apcs[k];
//printf("Checking %f CMYK %f %f %f %f Lab %f %f %f\n",
// ss, dev[j][0], dev[j][1], dev[j][2], dev[j][3],
// pcs[j][0], pcs[j][1], pcs[j][2]);
if (ss <= 0.0) {
nm = 1;
printf("NonMon %f at CMYK %f %f %f %f Lab %f %f %f\n",
ss, dev[j][0], dev[j][1], dev[j][2], dev[j][3],
pcs[j][0], pcs[j][1], pcs[j][2]);
}
}
//printf("\n");
/* Display just the non mono threads */
if (nm && dovrml) {
for (j = 0; j < gres; j++)
wrl->add_vertex(wrl, 0, pcs[j]);
}
if (verb) {
printf("."); fflush(stdout);
}
}
}
}
}
if (dovrml) {
wrl->make_lines(wrl, 0, gres);
wrl->del(wrl);
}
/* Done with lookup object */
luo->del(luo);
rd_icco->del(rd_icco);
rd_fp->del(rd_fp);
return 0;
}
/* ------------------------------------------------ */
/* Basic printf type error() and warning() routines */
void
error(char *fmt, ...)
{
va_list args;
fprintf(stderr,"icctest: Error - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit (-1);
}
void
warning(char *fmt, ...)
{
va_list args;
fprintf(stderr,"icctest: Warning - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}

View File

@@ -0,0 +1,352 @@
/*
* Create an ICC V2.4 compatible matrix display profile.
*
* Author: Graeme W. Gill
* Date: 8/2/2008
* Version: 1.00
*
* Copyright 2006 - 2014 Graeme W. Gill
*
* This material is licensed with an "MIT" free use license:-
* see the License4.txt file in this directory for licensing details.
*
* Based on icc/lutest.c
*/
/*
* TTBD:
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "icc.h"
void error(char *fmt, ...), warning(char *fmt, ...);
void usage(void) {
fprintf(stderr,"Create a Matrix Display ICC profile\n");
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: mkDispProf [-v level] outfile\n");
fprintf(stderr," -v Verbose\n");
exit(1);
}
/* sRGB like device gamma encoded value to linear value 0.0 .. 1.0 */
static double gdv2dv(double iv) {
double ov;
if (iv < 0.04045)
ov = iv/12.92;
else
ov = pow((iv + 0.055)/1.055, 2.4);
return ov;
}
int
main(
int argc,
char *argv[]
) {
int fa,nfa;
icmErr e = { 0, { '\000'} };
char out_name[1000];
icmFile *wr_fp;
icc *wr_icco;
int rv = 0;
int verb = 0;
if (argc < 2)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
if (argv[fa][1] == '?')
usage();
/* Verbosity */
else if (argv[fa][1] == 'v' || argv[fa][1] == 'V') {
verb = 1;
}
else
usage();
}
else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strcpy(out_name,argv[fa]);
/* ---------------------------------------- */
/* Create a matrix/shaper based XYZ profile */
/* ---------------------------------------- */
icm_err_clear_e(&e);
/* Open up the file for writing */
if ((wr_fp = new_icmFileStd_name(&e, out_name,"w")) == NULL)
error ("Write: Can't open file '%s', failed with 0x%x, '%s'",out_name,e.c, e.m);
if ((wr_icco = new_icc(&e)) == NULL)
error ("Write: Creation of ICC object failed with 0x%x, '%s'",e.c, e.m);
/* Add all the tags required */
/* The header: */
{
icmHeader *wh = wr_icco->header;
/* Values that must be set before writing */
wh->deviceClass = icSigDisplayClass;
wh->colorSpace = icSigRgbData; /* It's RGB space */
wh->pcs = icSigXYZData;
wh->renderingIntent = icPerceptual;
/* Values that should be set before writing */
wh->manufacturer = icmstr2tag("????");
wh->model = icmstr2tag("????");
}
/* Profile Description Tag: */
{
icmCommonTextDescription *wo;
char *dst;
dst = "sRGB like Matrix Display profile";
if ((wo = (icmCommonTextDescription *)wr_icco->add_tag(
wr_icco, icSigProfileDescriptionTag, icmSigCommonTextDescriptionType)) == NULL)
error("add_tag failed: %d, %s",wr_icco->e.c,wr_icco->e.m);
wo->count = strlen(dst)+1; /* Allocated and used size of desc, inc null */
wo->allocate(wo);/* Allocate space */
strcpy(wo->desc, dst); /* Copy the string in */
}
/* Copyright Tag: */
{
icmCommonTextDescription *wo;
char *crt = "Copyright tag goes here";
if ((wo = (icmCommonTextDescription *)wr_icco->add_tag(
wr_icco, icSigCopyrightTag, icmSigCommonTextDescriptionType)) == NULL)
error("add_tag failed: %d, %s",wr_icco->e.c,wr_icco->e.m);
wo->count = strlen(crt)+1; /* Allocated and used size of text, inc null */
wo->allocate(wo);/* Allocate space */
strcpy(wo->desc, crt); /* Copy the text in */
}
/* Could add other relevant tags here, such as:
Device Manufacturers Description Tag
Device Model Description Tag
Device technology Tag
Viewing conditions Description Tag
Viewing conditions
Display Luminance Tag
Measurement information Tag
etc.
*/
/* Setup the primaries */
{
/* Compute primaries as XYZ */
double wrgb[4][3] = { /* Primaries in Yxy from the standard */
{ 1.0, 0.3127, 0.3290 }, /* White */
{ 1.0, 0.6400, 0.3300 }, /* Red */
{ 1.0, 0.3000, 0.6000 }, /* Green */
{ 1.0, 0.1500, 0.0600 } /* Blue */
};
double mat[3][3];
int i;
/* Convert yxy to normalised 3x3 matrix */
icmRGBYxyprim2matrix(wrgb[1], wrgb[2], wrgb[3], wrgb[0], mat, wrgb[0]);
icmTranspose3x3(mat, mat);
#ifdef NEVER /* Dump XYZ */
printf("sRGB: XYZ\n");
printf("{ %f, %f, %f }, /* Red */\n"
"{ %f, %f, %f }, /* Green */\n"
"{ %f, %f, %f }, /* Blue */\n"
"{ %f, %f, %f } /* White */\n",
mat[0][0], mat[0][1], mat[0][2],
mat[1][0], mat[1][1], mat[1][2],
mat[2][0], mat[2][1], mat[2][2],
wrgb[0][0], wrgb[0][1], wrgb[0][2]);
#endif
#ifdef NEVER /* Dump xyz */
{
double mat2[4][3];
double tt;
for (i = 0; i < 3; i++) {
tt = mat[i][0] + mat[i][1] + mat[i][2];
mat2[i][0] = mat[i][0] / tt;
mat2[i][1] = mat[i][1] / tt;
mat2[i][2] = mat[i][2] / tt;
}
tt = wrgb[0][0] + wrgb[0][1] + wrgb[0][2];
mat2[i][0] = wrgb[0][0] / tt;
mat2[i][1] = wrgb[0][1] / tt;
mat2[i][2] = wrgb[0][2] / tt;
printf("sRGB: xyz\n");
printf("{ %f, %f, %f }, /* Red */\n"
"{ %f, %f, %f }, /* Green */\n"
"{ %f, %f, %f }, /* Blue */\n"
"{ %f, %f, %f } /* White */\n",
mat2[0][0], mat2[0][1], mat2[0][2],
mat2[1][0], mat2[1][1], mat2[1][2],
mat2[2][0], mat2[2][1], mat2[2][2],
mat2[3][0], mat2[3][1], mat2[3][2]);
}
#endif
/* White Point Tag: */
{
icmXYZArray *wo;
if ((wo = (icmXYZArray *)wr_icco->add_tag(
wr_icco, icSigMediaWhitePointTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",wr_icco->e.c,wr_icco->e.m);
wo->count = 1;
wo->allocate(wo); /* Allocate space */
wo->data[0].X = wrgb[0][0];
wo->data[0].Y = wrgb[0][1];
wo->data[0].Z = wrgb[0][2];
}
/* Black Point Tag: */
{
icmXYZArray *wo;
if ((wo = (icmXYZArray *)wr_icco->add_tag(
wr_icco, icSigMediaBlackPointTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",wr_icco->e.c,wr_icco->e.m);
wo->count = 1;
wo->allocate(wo); /* Allocate space */
wo->data[0].X = 0.00;
wo->data[0].Y = 0.00;
wo->data[0].Z = 0.00;
}
/* Red, Green and Blue Colorant Tags: */
{
icmXYZNumber white;
icmXYZArray *wor, *wog, *wob;
double fromAbs[3][3];
double d50m[3][3];
/* Convert to D50 adapated */
icmAry2XYZ(white, wrgb[0]);
wr_icco->chromAdaptMatrix(wr_icco, ICM_CAM_NONE, NULL, fromAbs, icmD50, white);
icmMulBy3x3(d50m[0], fromAbs, mat[0]);
icmMulBy3x3(d50m[1], fromAbs, mat[1]);
icmMulBy3x3(d50m[2], fromAbs, mat[2]);
/* Make sure rounding doesn't wreck white point */
quantizeRGBprimsS15Fixed16(d50m);
if ((wor = (icmXYZArray *)wr_icco->add_tag(
wr_icco, icSigRedColorantTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",rv,wr_icco->e.m);
if ((wog = (icmXYZArray *)wr_icco->add_tag(
wr_icco, icSigGreenColorantTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",rv,wr_icco->e.m);
if ((wob = (icmXYZArray *)wr_icco->add_tag(
wr_icco, icSigBlueColorantTag, icSigXYZArrayType)) == NULL)
error("add_tag failed: %d, %s",rv,wr_icco->e.m);
wor->count = wog->count = wob->count = 1;
wor->allocate(wor); /* Allocate space */
wog->allocate(wog);
wob->allocate(wob);
wor->data[0].X = d50m[0][0]; wor->data[0].Y = d50m[0][1]; wor->data[0].Z = d50m[0][2];
wog->data[0].X = d50m[1][0]; wog->data[0].Y = d50m[1][1]; wog->data[0].Z = d50m[1][2];
wob->data[0].X = d50m[2][0]; wob->data[0].Y = d50m[2][1]; wob->data[0].Z = d50m[2][2];
}
}
/* Red, Green and Blue Gamma Curve Tags: */
{
icmCurve *wor, *wog, *wob;
int i;
if ((wor = (icmCurve *)wr_icco->add_tag(
wr_icco, icSigRedTRCTag, icSigCurveType)) == NULL)
error("add_tag failed: %d, %s",rv,wr_icco->e.m);
wor->ctype = icmCurveSpec;
wor->count = 1024;
wor->allocate(wor); /* Allocate space */
for (i = 0; i < wor->count; i++)
wor->data[i] = gdv2dv(i/(wor->count-1.0));
/* Link other channels to the red */
if ((wog = (icmCurve *)wr_icco->link_tag(
wr_icco, icSigGreenTRCTag, icSigRedTRCTag)) == NULL)
error("link_tag failed: %d, %s",rv,wr_icco->e.m);
if ((wob = (icmCurve *)wr_icco->link_tag(
wr_icco, icSigBlueTRCTag, icSigRedTRCTag)) == NULL)
error("link_tag failed: %d, %s",rv,wr_icco->e.m);
}
/* Write the file out */
if ((rv = wr_icco->write(wr_icco,wr_fp,0)) != 0)
error ("Write file: %d, %s",rv,wr_icco->e.m);
wr_icco->del(wr_icco);
wr_fp->del(wr_fp);
return 0;
}
/* ------------------------------------------------ */
/* Basic printf type error() and warning() routines */
void
error(char *fmt, ...) {
va_list args;
fprintf(stderr,"mkDispProf: Error - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit (-1);
}
void
warning(char *fmt, ...) {
va_list args;
fprintf(stderr,"mkDispProf: Warning - ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}

BIN
Argyll_V3.5.0/icc/sRGB.icm Executable file

Binary file not shown.

View File

@@ -0,0 +1,226 @@
/* Test the CIE delta E 2000 code */
#include <stdio.h>
#include <math.h>
#include "icc.h"
/* Reference data */
#define NTESTS 34
/* From the Sharma, Wu and Dalal "Implementation Notes" etc. paper: */
struct {
double Lab1[3];
double Lab2[3];
double de;
} ref[NTESTS] = {
{ 50.0000, 2.6772, -79.7751, 50.0000, 0.0000, -82.7485, 2.0425 },
{ 50.0000, 3.1571, -77.2803, 50.0000, 0.0000, -82.7485, 2.8615 },
{ 50.0000, 2.8361, -74.0200, 50.0000, 0.0000, -82.7485, 3.4412 },
{ 50.0000, -1.3802, -84.2814, 50.0000, 0.0000, -82.7485, 1.0000 },
{ 50.0000, -1.1848, -84.8006, 50.0000, 0.0000, -82.7485, 1.0000 },
{ 50.0000, -0.9009, -85.5211, 50.0000, 0.0000, -82.7485, 1.0000 },
{ 50.0000, 0.0000, 0.0000, 50.0000, -1.0000, 2.0000, 2.3669 },
{ 50.0000, -1.0000, 2.0000, 50.0000, 0.0000, 0.0000, 2.3669 },
{ 50.0000, 2.4900, -0.0010, 50.0000, -2.4900, 0.0009, 7.1792 },
{ 50.0000, 2.4900, -0.0010, 50.0000, -2.4900, 0.0010, 7.1792 },
{ 50.0000, 2.4900, -0.0010, 50.0000, -2.4900, 0.0011, 7.2195 },
{ 50.0000, 2.4900, -0.0010, 50.0000, -2.4900, 0.0012, 7.2195 },
{ 50.0000, -0.0010, 2.4900, 50.0000, 0.0009, -2.4900, 4.8045 },
{ 50.0000, -0.0010, 2.4900, 50.0000, 0.0010, -2.4900, 4.8045 },
{ 50.0000, -0.0010, 2.4900, 50.0000, 0.0011, -2.4900, 4.7461 },
{ 50.0000, 2.5000, 0.0000, 50.0000, 0.0000, -2.5000, 4.3065 },
{ 50.0000, 2.5000, 0.0000, 73.0000, 25.0000, -18.0000, 27.1492 },
{ 50.0000, 2.5000, 0.0000, 61.0000, -5.0000, 29.0000, 22.8977 },
{ 50.0000, 2.5000, 0.0000, 56.0000, -27.0000, -3.0000, 31.9030 },
{ 50.0000, 2.5000, 0.0000, 58.0000, 24.0000, 15.0000, 19.4535 },
{ 50.0000, 2.5000, 0.0000, 50.0000, 3.1736, 0.5854, 1.0000 },
{ 50.0000, 2.5000, 0.0000, 50.0000, 3.2972, 0.0000, 1.0000 },
{ 50.0000, 2.5000, 0.0000, 50.0000, 1.8634, 0.5757, 1.0000 },
{ 50.0000, 2.5000, 0.0000, 50.0000, 3.2592, 0.3350, 1.0000 },
{ 60.2574, -34.0099, 36.2677, 60.4626, -34.1751, 39.4387, 1.2644 },
{ 63.0109, -31.0961, -5.8663, 62.8187, -29.7946, -4.0864, 1.2630 },
{ 61.2901, 3.7196, -5.3901, 61.4292, 2.2480, -4.9620, 1.8731 },
{ 35.0831, -44.1164, 3.7933, 35.0232, -40.0716, 1.5901, 1.8645 },
{ 22.7233, 20.0904, -46.6940, 23.0331, 14.9730, -42.5619, 2.0373 },
{ 36.4612, 47.8580, 18.3852, 36.2715, 50.5065, 21.2231, 1.4146 },
{ 90.8027, -2.0831, 1.4410, 91.1528, -1.6435, 0.0447, 1.4441 },
{ 90.9257, -0.5406, -0.9208, 88.6381, -0.8985, -0.7239, 1.5381 },
{ 6.7747, -0.2908, -2.4247, 5.8714, -0.0985, -2.2286, 0.6377 },
{ 2.0776, 0.0795, -1.1350, 0.9033, -0.0636, -0.5514, 0.9082 }
};
double icmCIE2K(double *Lab1, double *Lab2);
int main(void) {
int rv = 0;
int i;
printf("Starting Test:\n");
#ifdef NEVER
for (i = 0; i < NTESTS; i++) {
printf("Lab1 = %f %f %f\n", ref[i].Lab1[0], ref[i].Lab1[1], ref[i].Lab1[2]);
printf("Lab2 = %f %f %f\n", ref[i].Lab2[0], ref[i].Lab2[1], ref[i].Lab2[2]);
printf("de = %f\n",ref[i].de);
}
#endif
/* Test it all out */
for (i = 0; i < NTESTS; i++) {
double de;
de = icmCIE2K(ref[i].Lab1, ref[i].Lab2);
if (fabs(de - ref[i].de) > 0.0001) {
printf("Error at index %d:\n",i);
printf("Lab1 = %f %f %f\n", ref[i].Lab1[0], ref[i].Lab1[1], ref[i].Lab1[2]);
printf("Lab2 = %f %f %f\n", ref[i].Lab2[0], ref[i].Lab2[1], ref[i].Lab2[2]);
printf("DeltaE is %f, should be %f\n\n",de,ref[i].de);
rv = 1;
}
de = icmCIE2K(ref[i].Lab2, ref[i].Lab1);
if (fabs(de - ref[i].de) > 0.0001) {
printf("Error at index %d:\n",i);
printf("Lab1 = %f %f %f\n", ref[i].Lab2[0], ref[i].Lab2[1], ref[i].Lab2[2]);
printf("Lab2 = %f %f %f\n", ref[i].Lab1[0], ref[i].Lab1[1], ref[i].Lab1[2]);
printf("DeltaE is %f, should be %f\n\n",de,ref[i].de);
rv = 1;
}
}
printf("Test Finished\n");
return rv;
}
#ifdef NEVER /* Test implementation in icc.c */
/* From the paper "The CIEDE2000 Color-Difference Formula: Implementation Notes, */
/* Supplementary Test Data, and Mathematical Observations", by */
/* Gaurav Sharma, Wencheng Wu and Edul N. Dalal, */
/* Color Res. Appl., vol. 30, no. 1, pp. 21-30, Feb. 2005. */
/* Return the CIEDE2000 Delta E color difference measure squared, for two Lab values */
double icmCIE2Ksq(double *Lab0, double *Lab1) {
double C1, C2;
double h1, h2;
double dL, dC, dH;
double dsq;
/* The trucated value of PI is needed to ensure that the */
/* test cases pass, as one of them lies on the edge of */
/* a mathematical discontinuity. The precision is still */
/* enough for any practical use. */
#define RAD2DEG(xx) (180.0/3.14159265358979 * (xx))
#define DEG2RAD(xx) (3.14159265358979/180.0 * (xx))
/* Compute Cromanance and Hue angles */
{
double C1ab, C2ab;
double Cab, Cab7, G;
double a1, a2;
C1ab = sqrt(Lab0[1] * Lab0[1] + Lab0[2] * Lab0[2]);
C2ab = sqrt(Lab1[1] * Lab1[1] + Lab1[2] * Lab1[2]);
Cab = 0.5 * (C1ab + C2ab);
Cab7 = pow(Cab,7.0);
G = 0.5 * (1.0 - sqrt(Cab7/(Cab7 + 6103515625.0)));
a1 = (1.0 + G) * Lab0[1];
a2 = (1.0 + G) * Lab1[1];
C1 = sqrt(a1 * a1 + Lab0[2] * Lab0[2]);
C2 = sqrt(a2 * a2 + Lab1[2] * Lab1[2]);
if (C1 < 1e-9)
h1 = 0.0;
else {
h1 = RAD2DEG(atan2(Lab0[2], a1));
if (h1 < 0.0)
h1 += 360.0;
}
if (C2 < 1e-9)
h2 = 0.0;
else {
h2 = RAD2DEG(atan2(Lab1[2], a2));
if (h2 < 0.0)
h2 += 360.0;
}
}
/* Compute delta L, C and H */
{
double dh;
dL = Lab1[0] - Lab0[0];
dC = C2 - C1;
if (C1 < 1e-9 || C2 < 1e-9) {
dh = 0.0;
} else {
dh = h2 - h1;
if (dh > 180.0)
dh -= 360.0;
else if (dh < -180.0)
dh += 360.0;
}
dH = 2.0 * sqrt(C1 * C2) * sin(DEG2RAD(0.5 * dh));
}
{
double L, C, h, T;
double hh, ddeg;
double C7, RC, L50sq, SL, SC, SH, RT;
double dLsq, dCsq, dHsq, RCH;
L = 0.5 * (Lab0[0] + Lab1[0]);
C = 0.5 * (C1 + C2);
if (C1 < 1e-9 || C2 < 1e-9) {
h = h1 + h2;
} else {
h = h1 + h2;
if (fabs(h1 - h2) > 180.0) {
if (h < 360.0)
h += 360.0;
else if (h >= 360.0)
h -= 360.0;
}
h *= 0.5;
}
T = 1.0 - 0.17 * cos(DEG2RAD(h-30.0)) + 0.24 * cos(DEG2RAD(2.0 * h))
+ 0.32 * cos(DEG2RAD(3.0 * h + 6.0)) - 0.2 * cos(DEG2RAD(4.0 * h - 63.0));
hh = (h - 275.0)/25.0;
ddeg = 30.0 * exp(-hh * hh);
C7 = pow(C,7.0);
RC = 2.0 * sqrt(C7/(C7 + 6103515625.0));
L50sq = (L - 50.0) * (L - 50.0);
SL = 1.0 + (0.015 * L50sq)/sqrt(20.0 + L50sq);
SC = 1.0 + 0.045 * C;
SH = 1.0 + 0.015 * C * T;
RT = -sin(DEG2RAD(2 * ddeg)) * RC;
dLsq = dL/SL;
dCsq = dC/SC;
dHsq = dH/SH;
RCH = RT * dCsq * dHsq;
dLsq *= dLsq;
dCsq *= dCsq;
dHsq *= dHsq;
dsq = dLsq + dCsq + dHsq + RCH;
}
return dsq;
#undef RAD2DEG
#undef DEG2RAD
}
/* Return the CIE2DE000 Delta E color difference measure for two Lab values */
double icmCIE2K(double *Lab0, double *Lab1) {
return sqrt(icmCIE2Ksq(Lab0, Lab1));
}
#endif /* NEVER */

197
Argyll_V3.5.0/icc/todo.txt Executable file
View File

@@ -0,0 +1,197 @@
Notes on changes needed for V4.2 (OLD - outdated by icclib V3.0)
--------------------------------------------
Spec name/version/file version relationship.
This is more complicated that it really should be:
Spec. Name Spec. Version File Version
---------- ------------- ------------
ICC.1:2004-10 4.2 4.2.0 <-- target icclib4
ICC.1:2003-09 4.1 4.1.0
ICC.1:2001-12 4.0 4.0.0
ICC.1:2001-04 (3.7?) 2.4.0
ICC.1A:1999-04 (3.6?) 2.3.0
ICC.1:1998-09 (3.5?) 2.2.0
(Version 3.4) 3.4 2.1.0 (a) <-- current icclib
(Version 3.3) 3.3 2.1.0
(Version 3.2) 3.2 2.0.0 (b)
(Version 3.01) 3.01 2.0.0 (a)
(Version 3.0) 3.0 2.0.0
-----------------------------
There are other changes from V2.1 in later versions,
such as:
2.3.0
Chromaticity Tag added
2.4.0
Lut tables now allowed for monochrome
Added chromaticAdaptationTag
Input, Display, Output and Colorspace LUT profiles
now support all 3 intents.
Can this be made backwards compatible without
messing about with specific code for other versions ??
This doesn't seem possible. The profile generator code and icclib
would seem to need to know which version they were generating,
for assured backwards compatibility with other CMMs.
-----------------------------
Should add "guess ink limit" support to ease gamut finding
from profiles. (Implemented in xicc at the moment) ?
-----------------------------
Add usage of #def icVersionNumberV41 when "V4" flag is active.
Tags needed since V2.1
icSigChromaticAdaptationTag = 0x63686164L, /* 'chad' V2.4+ */
icSigChromaticityTag = 0x6368726DL, /* 'chrm' V2.3+ */
icSigColorantOrderTag = 0x636C726FL, /* 'clro' V4.0+ */
icSigColorantTableTag = 0x636C7274L, /* 'clrt' V4.0+ */
icSigColorantTableOutTag = 0x636C6F74L, /* 'clot' V4.0+ */
icSigDeviceSettingsTag = 0x64657673L, /* 'devs' V2.2 - V4.0 */
icSigOutputResponseTag = 0x72657370L, /* 'resp' V2.2+ */
Tag types needed since V2.1
icSigDeviceSettingsType = 0x64657673L, /* 'devs' V2.2 - V4.0 */
icSigChromaticityTag = 0x6368726DL, /* 'chrm' V2.3+ */
icSigColorantOrderType = 0x636C726FL, /* 'clro' V4.0+ */
icSigColorantTableType = 0x636C7274L, /* 'clrt' V4.0+ */
icSigLutAtoBType = 0x6d414220L, /* 'mAB ' V4.0+ */
icSigLutBtoAType = 0x6d424120L, /* 'mBA ' V4.0+ */
icSigMultiLocalizedUnicodeType = 0x6D6C7563L, /* 'mluc' V4.0+ */
icSigParametricCurveType = 0x70617261L, /* 'para' V4.0+ */
icSigResponseCurveSet16Type = 0x72637332L, /* 'rcs2' V2.2 - V4.0 */
Stuff to deal with in implementing ICCV4:
-------------------
Make sure DLL/SO version is compilable ??
Add V4 flag in main icc struct (DONE), and some way of setting it before tags
are added.
Date & time being UTC.
- add flag when setting ?
- display both when dumping ?
- have both in structure when reading ?
- or simply not handle this ??
Check all padding is zero during writing - DONE
Implement MD5 generation on profile writing - DONE
Implement MD5 check method on read profile ?
Cross check MD5 against external V4 profiles. Cross check with cygwin md5sum!
Colorant table tag needed in V4 for xCLR devices.
colorantTableTag requirement for xCLR device link profiles.
Add check that tags are unique within a profile ?
Configure conformance to run as V4.2 or V2.4 on writing, and accept V4.X or V2.X on
reading. Don't try and implement detailed minor version behaviour.
Have some sort of table to embody valid tags and tag types within the two major
version numbers (2 & 4) ??
Check that non A2B0 and B2A0 intents are allowed for Input, Display & Colorspace
profiles ??
V4 mandates a chromatic adaptation tag for any profile that requires a white point
tag & not D50. Add to V4 check, & generate chromatic adaptation tag for V2 & V4
creation (method ?). Need to carefully read spec. to understand what chromatic
adaptation tag is meant to represent.
Implement absolute<->PCS object to represent functionality of chramatic adaptation,
analogous to conversion object.
Check mono profile black and white interpretation.
Matrix/shaper in V4 has clipping requirements. Should these be honoured ??
Maybe make this optional via a run time flag ?
May be best to have multiple conformance flags (Absolute Intent etc. ?)
Check icclink set header rendering intents correctly for device links.
Implemenmt parametric curve type as extra icmCurveStyle(s), and use icmCurve object to
do the work.
Implement MultiLocalizedUnicodeType as overload of icmTextDescription, or new tagtype ??
[ Create common class having plain ASCII that TextDescription and MultiLocalizedUnicode
inheret from. ]
- - - - -
Implement icSigLutAtoBType and icSigLutBtoAType as overloads of icmLut ??
If so, add new icmLuAlgType types for AtoB and BtoA conversions (NO - more complicated)
- OR -
switch to single superset Lut type ?? (YES - best solution) :-
Should a more extensive general model be considered, as a superset of V4 ?? (YES)
pcs/abs -> Curves -> matrix -> curves -> lut -> curves -> matrix -> curves -> pcs/abs
[ or asymetric ??: (NO)
pcs->curves->lut->3x3+3matrix->curves->pcs/abs (dev->PCS, PCS->PCS, dev->dev)
pcs/abs->curves->3x3+3matrix->curves->lut->curves (PCS->dev) ]
Could use this as universal transform method, even for matrix profiles (don't use old style
matrix/shaper or LUT at all internaly ?) (YES - need to accomodate V2 & V4 though).
Add new methods to setup the transform stages, with current set mathods implemented
as backwards compatible ? Have multiple methods rather than a single "set" ?
( - how are ranges determined in latter case ?)
Finish support for generic 3 stage conversion view (input per chan, cross chan, output per chan.),
and support this in icclib4.
Use bit flags to indicate which stages are valid.
Flags effectively replace "algorithm" flag.
Flag combination set determines how transform can be represented by a profile
(Mono, Matrix, V2Lut, V4Lut etc.).
Have flags for "separable" (i.e. channel independent) and
"reversable".
Support implementing a universal transform both forwards and
backwards from a given set of ICC tags (backwards won't be
valid for some tags, ie. Lut).
lookup object acts as ideal abstract above exact tag representation within
a profile. Use this model for other aspects of ICC profiles.
Extend to simplify xicc/icc relationship - make xicc a true inheriting
class, and add whatever hooks are needed into icclib4 to make this work.
ICC tags -> luo -> transform
ICC tags <- luo <- Set transform
What impact does this have on memory usage though ?
- Makes sure transform is completely independent of
tags or profile after setting up, so that tags and/or
profile can be released. [ Use reference counting ? ]
- - - - - -
Split icc.c into 3 levels:
1 Basic support (I/O, primitives)
Toolkit for buiding ICC like file formats, but not
specic to the actual ICC file. Can be used to
create custom tags, and custom ICC like files (e.g. calibration)
2 Specific to ICC format, tags etc.
3 ICC color transform objects etc.
Allow for inheretance, so that xicc can be implemented
much more elegantly.