Skip to content
Snippets Groups Projects
Commit 96ff644a authored by jst@mozilla.com's avatar jst@mozilla.com
Browse files

Include modules/lcms in list of mirrored directories. Old history only available in CVS.

parent 36deca45
No related branches found
No related tags found
No related merge requests found
Showing
with 16270 additions and 0 deletions
Main Author:
------------
Marti Maria <info@littlecms.com>
Little CMS
Copyright (c) 1998-2007 Marti Maria Saguer
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.
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is lcms mozilla build integration.
#
# The Initial Developer of the Original Code is IBM Corporation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = lcms
DIRS = include src
include $(topsrcdir)/config/rules.mk
New in ver 1.17
===============
Changes in API
----------------------
WIN64 support
_vsnprintf wrap
BOOL replaced by LCMSBOOL
cmsSetLanguage parameters changed to match ICC spec
removed support for extended gamut descriptor (was never fully implemented)
cmsFLAGS_NODEFAULTRESOURCEDEF moved to 0x01000000
_cmsMalloc wrapper for malloc
_cmsFree wrapper for free
Implementation
----------------------
All errors moved to fatal, since there is no easy recovery strategy
Vulnerability fixes on cmsio1.c
Status check, many functions now check the status when calling other functions. Improved robustness against ill-formed profiles.
_cmsSaveProfile didn't copy tags from a file based profile, fixed.
Utilities
----------
icctrans: CMYKcm support wrongly implemented, fixed.
icclink: linking 3 to 7 channels didn't work in some cases, fixed.
Read.me for release 1.17
========================
Little cms
Copyright (C) 1998-2007 Marti Maria
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.
The lcms library is now distributed under
MIT PUBLIC LICENSE
See file COPYING. for details
This is the 15th. public release the engine. It has been tested
across several versions before, but it is possible some
bugs still arises. If so, sorry for the inconvenience, and
please feel free to submit any suggestion/solution (if you can
found it) at:
info@littlecms.com
Note that the aesthetics of resulting colors are due only to
profiles, and not as consequence of the lcms package.
The main site for the package is located at
http://www.littlecms.com
or
http://www.lcms.coloraid.de
Littlecms has also a mailing list on:
http://lists.sourceforge.net/lists/listinfo/lcms-user
Looking forward the lcms project would grow in future, I will
welcome any contribution/optimization/enhancement.
Enjoy!
About profiles
==============
The demo of this package includes some profiles for colorspace
conversions. I figure all of them are in public domain, but
since some contains copyright notice, I will enumerate here
the sources:
Sun Microsystems Java SDK (widely available)
Kodak public FTP site: ftp.kodak.com
ICM Stress demo from microsoft. www.microsoft.com
sRGB from sRGB site www.srgb.com
If you found any of these not to be in public domain,
please notify me. I will remove the offending profile as soon as
posible.
Additional files
================
ICC34.h is the header file the International Color Consortium
has posted for version spec 3.4, with some minor modifications
for improving portability.
You can reach it at
http://www.color.org
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is lcms mozilla build integration.
#
# The Initial Developer of the Original Code is IBM Corporation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = lcms
EXPORTS = icc34.h lcms.h
include $(topsrcdir)/config/rules.mk
This diff is collapsed.
This diff is collapsed.
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is lcms mozilla build integration.
#
# The Initial Developer of the Original Code is IBM Corporation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = lcms
LIBRARY_NAME = mozlcms
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
DIST_INSTALL = 1
ifeq (,$(MOZ_ENABLE_LIBXUL)$(BUILD_STATIC_LIBS))
ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
ifndef GNU_CC
MAPFILE = $(LIBRARY_NAME).map
DEFFILE = $(win_srcdir)/lcms.def
endif
endif
ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
DEFINES += -DLCMS_DLL=1 -DLCMS_DLL_BUILD=1
else
VISIBILITY_FLAGS =
endif
endif
REQUIRES = $(LCMS_REQUIRES) \
$(NULL)
CSRCS = cmscnvrt.c cmserr.c cmsgamma.c cmsgmt.c cmsintrp.c cmsio1.c \
cmslut.c cmsmatsh.c cmsmtrx.c cmspack.c cmspcs.c cmswtpnt.c \
cmsxform.c cmssamp.c cmscam97.c cmsnamed.c cmsps2.c cmscam02.c \
cmsvirt.c cmscgats.c cmsio0.c
LOCAL_INCLUDES += -I../include
include $(topsrcdir)/config/rules.mk
//
// Little cms
// Copyright (C) 1998-2007 Marti Maria
//
// 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.
// CIECAM 02 appearance model. Many thanks to Jordi Vilar for the debugging.
#include "lcms.h"
LCMSAPI LCMSHANDLE LCMSEXPORT cmsCIECAM02Init(LPcmsViewingConditions pVC);
LCMSAPI void LCMSEXPORT cmsCIECAM02Done(LCMSHANDLE hModel);
LCMSAPI void LCMSEXPORT cmsCIECAM02Forward(LCMSHANDLE hModel, LPcmsCIEXYZ pIn, LPcmsJCh pOut);
LCMSAPI void LCMSEXPORT cmsCIECAM02Reverse(LCMSHANDLE hModel, LPcmsJCh pIn, LPcmsCIEXYZ pOut);
// ---------- Implementation --------------------------------------------
typedef struct {
double XYZ[3];
double RGB[3];
double RGBc[3];
double RGBp[3];
double RGBpa[3];
double a, b, h, e, H, A, J, Q, s, t, C, M;
double abC[2];
double abs[2];
double abM[2];
} CAM02COLOR, *LPCAM02COLOR;
typedef struct {
CAM02COLOR adoptedWhite;
double LA, Yb;
double F, c, Nc;
int surround;
double n, Nbb, Ncb, z, FL, D;
} cmsCIECAM02, *LPcmsCIECAM02;
static
double compute_n(LPcmsCIECAM02 pMod)
{
return(pMod -> Yb / pMod -> adoptedWhite.XYZ[1]);
}
static
double compute_z(LPcmsCIECAM02 pMod)
{
return(1.48 + pow(pMod -> n, 0.5));
}
static
double computeNbb(LPcmsCIECAM02 pMod)
{
return(0.725 * pow((1.0 / pMod -> n), 0.2));
}
static
double computeFL(LPcmsCIECAM02 pMod)
{
double k, FL;
k = 1.0 / ((5.0 * pMod->LA) + 1.0);
FL = 0.2 * pow(k, 4.0) * (5.0 * pMod->LA) + 0.1 *
(pow((1.0 - pow(k, 4.0)), 2.0)) *
(pow((5.0 * pMod->LA), (1.0 / 3.0)));
return FL;
}
static
double computeD(LPcmsCIECAM02 pMod)
{
double D;
D = pMod->F - (1.0/3.6)*(exp(((-pMod ->LA-42) / 92.0)));
return D;
}
static
CAM02COLOR XYZtoCAT02(CAM02COLOR clr)
{
clr.RGB[0] = (clr.XYZ[0] * 0.7328) + (clr.XYZ[1] * 0.4296) + (clr.XYZ[2] * -0.1624);
clr.RGB[1] = (clr.XYZ[0] * -0.7036) + (clr.XYZ[1] * 1.6975) + (clr.XYZ[2] * 0.0061);
clr.RGB[2] = (clr.XYZ[0] * 0.0030) + (clr.XYZ[1] * 0.0136) + (clr.XYZ[2] * 0.9834);
return clr;
}
static
CAM02COLOR ChromaticAdaptation(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
int i;
for (i = 0; i < 3; i++) {
clr.RGBc[i] = ((pMod -> adoptedWhite.XYZ[1] *
(pMod->D / pMod -> adoptedWhite.RGB[i])) +
(1.0 - pMod->D)) * clr.RGB[i];
}
return clr;
}
static
CAM02COLOR CAT02toHPE (CAM02COLOR clr)
{
double M[9];
M[0] =(( 0.38971 * 1.096124) + (0.68898 * 0.454369) + (-0.07868 * -0.009628));
M[1] =(( 0.38971 * -0.278869) + (0.68898 * 0.473533) + (-0.07868 * -0.005698));
M[2] =(( 0.38971 * 0.182745) + (0.68898 * 0.072098) + (-0.07868 * 1.015326));
M[3] =((-0.22981 * 1.096124) + (1.18340 * 0.454369) + ( 0.04641 * -0.009628));
M[4] =((-0.22981 * -0.278869) + (1.18340 * 0.473533) + ( 0.04641 * -0.005698));
M[5] =((-0.22981 * 0.182745) + (1.18340 * 0.072098) + ( 0.04641 * 1.015326));
M[6] =(-0.009628);
M[7] =(-0.005698);
M[8] =( 1.015326);
clr.RGBp[0] = (clr.RGBc[0] * M[0]) + (clr.RGBc[1] * M[1]) + (clr.RGBc[2] * M[2]);
clr.RGBp[1] = (clr.RGBc[0] * M[3]) + (clr.RGBc[1] * M[4]) + (clr.RGBc[2] * M[5]);
clr.RGBp[2] = (clr.RGBc[0] * M[6]) + (clr.RGBc[1] * M[7]) + (clr.RGBc[2] * M[8]);
return clr;
}
static
CAM02COLOR NonlinearCompression(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
int i;
double temp;
for (i = 0; i < 3; i++) {
if (clr.RGBp[i] < 0) {
temp = pow((-1.0 * pMod->FL * clr.RGBp[i] / 100.0), 0.42);
clr.RGBpa[i] = (-1.0 * 400.0 * temp) / (temp + 27.13) + 0.1;
}
else {
temp = pow((pMod->FL * clr.RGBp[i] / 100.0), 0.42);
clr.RGBpa[i] = (400.0 * temp) / (temp + 27.13) + 0.1;
}
}
clr.A = (((2.0 * clr.RGBpa[0]) + clr.RGBpa[1] +
(clr.RGBpa[2] / 20.0)) - 0.305) * pMod->Nbb;
return clr;
}
static
CAM02COLOR ComputeCorrelates(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
double a, b, temp, e, t, r2d, d2r;
a = clr.RGBpa[0] - (12.0 * clr.RGBpa[1] / 11.0) + (clr.RGBpa[2] / 11.0);
b = (clr.RGBpa[0] + clr.RGBpa[1] - (2.0 * clr.RGBpa[2])) / 9.0;
r2d = (180.0 / 3.141592654);
if (a == 0) {
if (b == 0) clr.h = 0;
else if (b > 0) clr.h = 90;
else clr.h = 270;
}
else if (a > 0) {
temp = b / a;
if (b > 0) clr.h = (r2d * atan(temp));
else if (b == 0) clr.h = 0;
else clr.h = (r2d * atan(temp)) + 360;
}
else {
temp = b / a;
clr.h = (r2d * atan(temp)) + 180;
}
d2r = (3.141592654 / 180.0);
e = ((12500.0 / 13.0) * pMod->Nc * pMod->Ncb) *
(cos((clr.h * d2r + 2.0)) + 3.8);
if (clr.h < 20.14) {
temp = ((clr.h + 122.47)/1.2) + ((20.14 - clr.h)/0.8);
clr.H = 300 + (100*((clr.h + 122.47)/1.2)) / temp;
}
else if (clr.h < 90.0) {
temp = ((clr.h - 20.14)/0.8) + ((90.00 - clr.h)/0.7);
clr.H = (100*((clr.h - 20.14)/0.8)) / temp;
}
else if (clr.h < 164.25) {
temp = ((clr.h - 90.00)/0.7) + ((164.25 - clr.h)/1.0);
clr.H = 100 + ((100*((clr.h - 90.00)/0.7)) / temp);
}
else if (clr.h < 237.53) {
temp = ((clr.h - 164.25)/1.0) + ((237.53 - clr.h)/1.2);
clr.H = 200 + ((100*((clr.h - 164.25)/1.0)) / temp);
}
else {
temp = ((clr.h - 237.53)/1.2) + ((360 - clr.h + 20.14)/0.8);
clr.H = 300 + ((100*((clr.h - 237.53)/1.2)) / temp);
}
clr.J = 100.0 * pow((clr.A / pMod->adoptedWhite.A),
(pMod->c * pMod->z));
clr.Q = (4.0 / pMod->c) * pow((clr.J / 100.0), 0.5) *
(pMod->adoptedWhite.A + 4.0) * pow(pMod->FL, 0.25);
t = (e * pow(((a * a) + (b * b)), 0.5)) /
(clr.RGBpa[0] + clr.RGBpa[1] +
((21.0 / 20.0) * clr.RGBpa[2]));
clr.C = pow(t, 0.9) * pow((clr.J / 100.0), 0.5) *
pow((1.64 - pow(0.29, pMod->n)), 0.73);
clr.M = clr.C * pow(pMod->FL, 0.25);
clr.s = 100.0 * pow((clr.M / clr.Q), 0.5);
return clr;
}
static
CAM02COLOR InverseCorrelates(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
double t, e, p1, p2, p3, p4, p5, hr, d2r;
d2r = 3.141592654 / 180.0;
t = pow( (clr.C / (pow((clr.J / 100.0), 0.5) *
(pow((1.64 - pow(0.29, pMod->n)), 0.73)))),
(1.0 / 0.9) );
e = ((12500.0 / 13.0) * pMod->Nc * pMod->Ncb) *
(cos((clr.h * d2r + 2.0)) + 3.8);
clr.A = pMod->adoptedWhite.A * pow(
(clr.J / 100.0),
(1.0 / (pMod->c * pMod->z)));
p1 = e / t;
p2 = (clr.A / pMod->Nbb) + 0.305;
p3 = 21.0 / 20.0;
hr = clr.h * d2r;
if (fabs(sin(hr)) >= fabs(cos(hr))) {
p4 = p1 / sin(hr);
clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
(p4 + (2.0 + p3) * (220.0 / 1403.0) *
(cos(hr) / sin(hr)) - (27.0 / 1403.0) +
p3 * (6300.0 / 1403.0));
clr.a = clr.b * (cos(hr) / sin(hr));
}
else {
p5 = p1 / cos(hr);
clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
(p5 + (2.0 + p3) * (220.0 / 1403.0) -
((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
(sin(hr) / cos(hr)));
clr.b = clr.a * (sin(hr) / cos(hr));
}
clr.RGBpa[0] = ((460.0 / 1403.0) * p2) +
((451.0 / 1403.0) * clr.a) +
((288.0 / 1403.0) * clr.b);
clr.RGBpa[1] = ((460.0 / 1403.0) * p2) -
((891.0 / 1403.0) * clr.a) -
((261.0 / 1403.0) * clr.b);
clr.RGBpa[2] = ((460.0 / 1403.0) * p2) -
((220.0 / 1403.0) * clr.a) -
((6300.0 / 1403.0) * clr.b);
return clr;
}
static
CAM02COLOR InverseNonlinearity(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
int i;
double c1;
for (i = 0; i < 3; i++) {
if ((clr.RGBpa[i] - 0.1) < 0) c1 = -1;
else c1 = 1;
clr.RGBp[i] = c1 * (100.0 / pMod->FL) *
pow(((27.13 * fabs(clr.RGBpa[i] - 0.1)) /
(400.0 - fabs(clr.RGBpa[i] - 0.1))),
(1.0 / 0.42));
}
return clr;
}
static
CAM02COLOR HPEtoCAT02(CAM02COLOR clr)
{
double M[9];
M[0] = (( 0.7328 * 1.910197) + (0.4296 * 0.370950));
M[1] = (( 0.7328 * -1.112124) + (0.4296 * 0.629054));
M[2] = (( 0.7328 * 0.201908) + (0.4296 * 0.000008) - 0.1624);
M[3] = ((-0.7036 * 1.910197) + (1.6975 * 0.370950));
M[4] = ((-0.7036 * -1.112124) + (1.6975 * 0.629054));
M[5] = ((-0.7036 * 0.201908) + (1.6975 * 0.000008) + 0.0061);
M[6] = (( 0.0030 * 1.910197) + (0.0136 * 0.370950));
M[7] = (( 0.0030 * -1.112124) + (0.0136 * 0.629054));
M[8] = (( 0.0030 * 0.201908) + (0.0136 * 0.000008) + 0.9834);;
clr.RGBc[0] = (clr.RGBp[0] * M[0]) + (clr.RGBp[1] * M[1]) + (clr.RGBp[2] * M[2]);
clr.RGBc[1] = (clr.RGBp[0] * M[3]) + (clr.RGBp[1] * M[4]) + (clr.RGBp[2] * M[5]);
clr.RGBc[2] = (clr.RGBp[0] * M[6]) + (clr.RGBp[1] * M[7]) + (clr.RGBp[2] * M[8]);
return (clr);
}
static
CAM02COLOR InverseChromaticAdaptation(CAM02COLOR clr, LPcmsCIECAM02 pMod)
{
int i;
for (i = 0; i < 3; i++) {
clr.RGB[i] = clr.RGBc[i] /
((pMod->adoptedWhite.XYZ[1] * pMod->D / pMod->adoptedWhite.RGB[i]) + 1.0 - pMod->D);
}
return(clr);
}
static
CAM02COLOR CAT02toXYZ(CAM02COLOR clr)
{
clr.XYZ[0] = (clr.RGB[0] * 1.096124) + (clr.RGB[1] * -0.278869) + (clr.RGB[2] * 0.182745);
clr.XYZ[1] = (clr.RGB[0] * 0.454369) + (clr.RGB[1] * 0.473533) + (clr.RGB[2] * 0.072098);
clr.XYZ[2] = (clr.RGB[0] * -0.009628) + (clr.RGB[1] * -0.005698) + (clr.RGB[2] * 1.015326);
return(clr);
}
LCMSHANDLE LCMSEXPORT cmsCIECAM02Init(LPcmsViewingConditions pVC)
{
LPcmsCIECAM02 lpMod;
if((lpMod = (LPcmsCIECAM02) _cmsMalloc(sizeof(cmsCIECAM02))) == NULL) {
return (LCMSHANDLE) NULL;
}
ZeroMemory(lpMod, sizeof(cmsCIECAM02));
lpMod ->adoptedWhite.XYZ[0] = pVC ->whitePoint.X;
lpMod ->adoptedWhite.XYZ[1] = pVC ->whitePoint.Y;
lpMod ->adoptedWhite.XYZ[2] = pVC ->whitePoint.Z;
lpMod -> LA = pVC ->La;
lpMod -> Yb = pVC ->Yb;
lpMod -> D = pVC ->D_value;
lpMod -> surround = pVC ->surround;
switch (lpMod -> surround) {
case AVG_SURROUND_4:
lpMod->F = 1.0; // Not included in CAM02
lpMod->c = 0.69;
lpMod->Nc = 1.0;
break;
case CUTSHEET_SURROUND:
lpMod->F = 0.8;
lpMod->c = 0.41;
lpMod->Nc = 0.8;
break;
case DARK_SURROUND:
lpMod -> F = 0.8;
lpMod -> c = 0.525;
lpMod -> Nc = 0.8;
break;
case DIM_SURROUND:
lpMod -> F = 0.9;
lpMod -> c = 0.59;
lpMod -> Nc = 0.95;
break;
default:
// Average surround
lpMod -> F = 1.0;
lpMod -> c = 0.69;
lpMod -> Nc = 1.0;
}
lpMod -> n = compute_n(lpMod);
lpMod -> z = compute_z(lpMod);
lpMod -> Nbb = computeNbb(lpMod);
lpMod -> FL = computeFL(lpMod);
if (lpMod -> D == D_CALCULATE ||
lpMod -> D == D_CALCULATE_DISCOUNT) {
lpMod -> D = computeD(lpMod);
}
lpMod -> Ncb = lpMod -> Nbb;
lpMod -> adoptedWhite = XYZtoCAT02(lpMod -> adoptedWhite);
lpMod -> adoptedWhite = ChromaticAdaptation(lpMod -> adoptedWhite, lpMod);
lpMod -> adoptedWhite = CAT02toHPE(lpMod -> adoptedWhite);
lpMod -> adoptedWhite = NonlinearCompression(lpMod -> adoptedWhite, lpMod);
return (LCMSHANDLE) lpMod;
}
void LCMSEXPORT cmsCIECAM02Done(LCMSHANDLE hModel)
{
LPcmsCIECAM02 lpMod = (LPcmsCIECAM02) (LPSTR) hModel;
if (lpMod) _cmsFree(lpMod);
}
void LCMSEXPORT cmsCIECAM02Forward(LCMSHANDLE hModel, LPcmsCIEXYZ pIn, LPcmsJCh pOut)
{
CAM02COLOR clr;
LPcmsCIECAM02 lpMod = (LPcmsCIECAM02) (LPSTR) hModel;
clr.XYZ[0] = pIn ->X;
clr.XYZ[1] = pIn ->Y;
clr.XYZ[2] = pIn ->Z;
clr = XYZtoCAT02(clr);
clr = ChromaticAdaptation(clr, lpMod);
clr = CAT02toHPE(clr);
clr = NonlinearCompression(clr, lpMod);
clr = ComputeCorrelates(clr, lpMod);
pOut ->J = clr.J;
pOut ->C = clr.C;
pOut ->h = clr.h;
}
void LCMSEXPORT cmsCIECAM02Reverse(LCMSHANDLE hModel, LPcmsJCh pIn, LPcmsCIEXYZ pOut)
{
CAM02COLOR clr;
LPcmsCIECAM02 lpMod = (LPcmsCIECAM02) (LPSTR) hModel;
clr.J = pIn -> J;
clr.C = pIn -> C;
clr.h = pIn -> h;
clr = InverseCorrelates(clr, lpMod);
clr = InverseNonlinearity(clr, lpMod);
clr = HPEtoCAT02(clr);
clr = InverseChromaticAdaptation(clr, lpMod);
clr = CAT02toXYZ(clr);
pOut ->X = clr.XYZ[0];
pOut ->Y = clr.XYZ[1];
pOut ->Z = clr.XYZ[2];
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//
// Little cms
// Copyright (C) 1998-2007 Marti Maria
//
// 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.
#include "lcms.h"
// As a rule, only the functions visible from API can signal
// errors.
void cdecl cmsSignalError(int ErrorCode, const char *ErrorText, ...);
int LCMSEXPORT cmsErrorAction(int lAbort);
void LCMSEXPORT cmsSetErrorHandler(cmsErrorHandlerFunction Fn);
// ******************************************************************
static int nDoAbort = LCMS_ERROR_ABORT;
static cmsErrorHandlerFunction UserErrorHandler = (cmsErrorHandlerFunction) NULL;
int LCMSEXPORT cmsErrorAction(int nAction)
{
int nOld = nDoAbort;
nDoAbort = nAction;
return nOld;
}
void LCMSEXPORT cmsSetErrorHandler(cmsErrorHandlerFunction Fn)
{
UserErrorHandler = Fn;
}
// Default error handler
void cmsSignalError(int ErrorCode, const char *ErrorText, ...)
{
va_list args;
if (nDoAbort == LCMS_ERROR_IGNORE) return;
va_start(args, ErrorText);
if (UserErrorHandler != NULL) {
char Buffer[1024];
vsnprintf(Buffer, 1023, ErrorText, args);
va_end(args);
if (UserErrorHandler(ErrorCode, Buffer)) {
return;
}
}
#if defined( __CONSOLE__ ) || defined( NON_WINDOWS )
fprintf(stderr, "lcms: Error #%d; ", ErrorCode);
vfprintf(stderr, ErrorText, args);
fprintf(stderr, "\n");
va_end(args);
if (nDoAbort == LCMS_ERROR_ABORT) exit(1);
#else
{
char Buffer1[1024];
char Buffer2[256];
snprintf(Buffer1, 767, "Error #%x; ", ErrorCode);
vsnprintf(Buffer2, 255, ErrorText, args);
strcat(Buffer1, Buffer2);
MessageBox(NULL, Buffer1, "Little cms",
MB_OK|MB_ICONSTOP|MB_TASKMODAL);
va_end(args);
if (nDoAbort == LCMS_ERROR_ABORT) {
#ifdef __BORLANDC__
_cexit();
#endif
FatalAppExit(0, "lcms is terminating application");
}
}
#endif
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment