Bug 723787 - Neutral sRGB profile matching Argyllcms sRGB.icm

Add gimp_lcms_create_srgb_profile() to libgimpcolor and use it where
we used to call cmsCreate_sRGBProfile().
This commit is contained in:
Elle Stone 2014-02-06 09:53:37 -05:00 committed by Michael Natterer
parent eafe1b9be3
commit 05c5ca3216
9 changed files with 159 additions and 14 deletions

View File

@ -53,6 +53,7 @@ AM_CPPFLAGS = \
$(GEGL_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(LCMS_CFLAGS) \
-I$(includedir)
EXTRA_DIST = \
@ -79,6 +80,8 @@ libgimpcolor_@GIMP_API_VERSION@_la_SOURCES = \
gimphsl.h \
gimphsv.c \
gimphsv.h \
gimplcms.c \
gimplcms.h \
gimppixbuf.c \
gimppixbuf.h \
gimprgb.c \
@ -96,6 +99,7 @@ libgimpcolorinclude_HEADERS = \
gimpcolorspace.h \
gimphsl.h \
gimphsv.h \
gimplcms.h \
gimppixbuf.h \
gimprgb.h
@ -112,6 +116,7 @@ libgimpcolor_@GIMP_API_VERSION@_la_LIBADD = \
$(GEGL_LIBS) \
$(CAIRO_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(LCMS_LIBS) \
$(libm)

View File

@ -31,6 +31,7 @@
#include <libgimpcolor/gimpcmyk.h>
#include <libgimpcolor/gimphsl.h>
#include <libgimpcolor/gimphsv.h>
#include <libgimpcolor/gimplcms.h>
#include <libgimpcolor/gimppixbuf.h>
#include <libgimpcolor/gimprgb.h>

99
libgimpcolor/gimplcms.c Normal file
View File

@ -0,0 +1,99 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* gimplcms.c
* Copyright (C) 2014 Michael Natterer <mitch@gimp.org>
* Elle Stone <ellestone@ninedegreesbelow.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <lcms2.h>
#include <gegl.h>
#include "gimpcolortypes.h"
#include "gimplcms.h"
/**
* SECTION: gimplcms
* @title: GimpLcms
* @short_description: Definitions and Functions relating to LCMS.
*
* Definitions and Functions relating to LCMS.
**/
/**
* gimp_lcms_create_srgb_profile:
*
* This function is a replacement for cmsCreate_sRGBProfile() and
* returns an sRGB profile that is functionally the same as the
* ArgyllCMS sRGB.icm profile. "Functionally the same" means it has
* the same red, green, and blue colorants and the V4 "chad"
* equivalent of the ArgyllCMS V2 white point. The profile TRC is also
* functionally equivalent to the ArgyllCMS sRGB.icm TRC and is the
* same as the LCMS sRGB built-in profile TRC.
*
* Return value: the sRGB cmsHPROFILE.
*
* Since: GIMP 2.10
**/
gpointer
gimp_lcms_create_srgb_profile (void)
{
cmsHPROFILE srgb_profile;
cmsMLU *description;
cmsCIExyY d65_srgb_specs = { 0.3127, 0.3290, 1.0 };
cmsCIExyYTRIPLE srgb_primaries_pre_quantized =
{
{ 0.639998686, 0.330010138, 1.0 },
{ 0.300003784, 0.600003357, 1.0 },
{ 0.150002046, 0.059997204, 1.0 }
};
cmsFloat64Number srgb_parameters[5] =
{ 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
cmsToneCurve *srgb_parametric_curve =
cmsBuildParametricToneCurve (NULL, 4, srgb_parameters);
cmsToneCurve *tone_curve[3];
tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric_curve;
srgb_profile = cmsCreateRGBProfile (&d65_srgb_specs,
&srgb_primaries_pre_quantized,
tone_curve);
cmsFreeToneCurve (srgb_parametric_curve);
description = cmsMLUalloc (NULL, 1);
cmsMLUsetASCII (description,
"en", "US",
"sRGB made with the correct white point and primaries.");
cmsWriteTag (srgb_profile, cmsSigProfileDescriptionTag, description);
cmsMLUfree (description);
cmsSetProfileVersion (srgb_profile, 2.1);
return srgb_profile;
}

40
libgimpcolor/gimplcms.h Normal file
View File

@ -0,0 +1,40 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* gimplcms.h
* Copyright (C) 2014 Michael Natterer <mitch@gimp.org>
* Elle Stone <ellestone@ninedegreesbelow.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
#endif
#ifndef __GIMP_LCMS_H__
#define __GIMP_LCMS_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gpointer gimp_lcms_create_srgb_profile (void);
G_END_DECLS
#endif /* __GIMP_LCMS_H__ */

View File

@ -357,7 +357,7 @@ color_config_get_rgb_profile (GimpColorConfig *config)
if (config->rgb_profile)
profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
return profile ? profile : cmsCreate_sRGBProfile ();
return profile ? profile : gimp_lcms_create_srgb_profile ();
}
static void

View File

@ -369,10 +369,10 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
cmsUInt32Number softproof_flags = 0;
if (! src_profile)
src_profile = cmsCreate_sRGBProfile ();
src_profile = gimp_lcms_create_srgb_profile ();
if (! dest_profile)
dest_profile = cmsCreate_sRGBProfile ();
dest_profile = gimp_lcms_create_srgb_profile ();
softproof_flags |= cmsFLAGS_SOFTPROOFING;
@ -409,10 +409,10 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
cmsUInt32Number display_flags = 0;
if (! src_profile)
src_profile = cmsCreate_sRGBProfile ();
src_profile = gimp_lcms_create_srgb_profile ();
if (! dest_profile)
dest_profile = cmsCreate_sRGBProfile ();
dest_profile = gimp_lcms_create_srgb_profile ();
if (config->display_use_black_point_compensation)
{

View File

@ -460,7 +460,7 @@ cdisplay_proof_changed (GimpColorDisplay *display)
if (! proof->profile)
return;
rgbProfile = cmsCreate_sRGBProfile ();
rgbProfile = gimp_lcms_create_srgb_profile ();
proofProfile = cmsOpenProfileFromFile (proof->profile, "r");

View File

@ -644,13 +644,13 @@ lcms_icc_apply (GimpColorConfig *config,
if (! src_profile)
{
src_profile = cmsCreate_sRGBProfile ();
src_profile = gimp_lcms_create_srgb_profile ();
lcms_sRGB_checksum (src_md5);
}
if (! dest_profile)
{
dest_profile = cmsCreate_sRGBProfile ();
dest_profile = gimp_lcms_create_srgb_profile ();
lcms_sRGB_checksum (dest_md5);
}
@ -726,7 +726,7 @@ lcms_icc_info (GimpColorConfig *config,
else
{
if (name) *name = g_strdup ("sRGB");
if (desc) *desc = g_strdup ("sRGB built-in");
if (desc) *desc = g_strdup ("sRGB made with the correct white point and primaries");
if (info) *info = g_strdup (_("Default RGB working space"));
}
@ -1503,7 +1503,7 @@ lcms_icc_combo_box_new (GimpColorConfig *config,
profile = lcms_load_profile (config->rgb_profile, NULL);
if (! profile)
profile = cmsCreate_sRGBProfile ();
profile = gimp_lcms_create_srgb_profile ();
name = lcms_icc_profile_get_desc (profile);
if (! name)
@ -1556,7 +1556,7 @@ lcms_dialog (GimpColorConfig *config,
}
if (! src_profile)
src_profile = cmsCreate_sRGBProfile ();
src_profile = gimp_lcms_create_srgb_profile ();
gimp_ui_init (PLUG_IN_BINARY, FALSE);
@ -1666,7 +1666,7 @@ lcms_dialog (GimpColorConfig *config,
}
else
{
dest_profile = cmsCreate_sRGBProfile ();
dest_profile = gimp_lcms_create_srgb_profile ();
}
if (dest_profile)

View File

@ -645,10 +645,10 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
}
}
/* use the built-in sRGB profile as fallback */
/* make the real sRGB profile as a fallback */
if (! rgb_profile)
{
rgb_profile = cmsCreate_sRGBProfile ();
rgb_profile = gimp_lcms_create_srgb_profile ();
}
if (config->display_intent ==