2014-02-06 22:53:37 +08:00
|
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimpcolorprofile.c
|
2014-02-06 22:53:37 +08:00
|
|
|
|
* Copyright (C) 2014 Michael Natterer <mitch@gimp.org>
|
|
|
|
|
* Elle Stone <ellestone@ninedegreesbelow.com>
|
2015-11-23 07:01:37 +08:00
|
|
|
|
* Øyvind Kolås <pippin@gimp.org>
|
2014-02-06 22:53:37 +08:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2018-07-12 05:27:07 +08:00
|
|
|
|
* <https://www.gnu.org/licenses/>.
|
2014-02-06 22:53:37 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2014-03-29 17:40:47 +08:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2014-02-06 22:53:37 +08:00
|
|
|
|
#include <lcms2.h>
|
|
|
|
|
|
2014-03-14 08:44:27 +08:00
|
|
|
|
#include <gio/gio.h>
|
2014-02-06 22:53:37 +08:00
|
|
|
|
#include <gegl.h>
|
|
|
|
|
|
2014-03-14 08:44:27 +08:00
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
2014-02-06 22:53:37 +08:00
|
|
|
|
#include "gimpcolortypes.h"
|
|
|
|
|
|
2015-06-03 15:41:23 +08:00
|
|
|
|
#include "gimpcolorprofile.h"
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2014-03-16 07:06:31 +08:00
|
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-12-15 06:16:38 +08:00
|
|
|
|
#ifndef TYPE_RGBA_DBL
|
|
|
|
|
#define TYPE_RGBA_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(0))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_GRAYA_HALF_FLT
|
|
|
|
|
#define TYPE_GRAYA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_GRAYA_FLT
|
|
|
|
|
#define TYPE_GRAYA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(4))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_GRAYA_DBL
|
|
|
|
|
#define TYPE_GRAYA_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(0))
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-05-27 06:33:56 +08:00
|
|
|
|
#ifndef TYPE_CMYKA_DBL
|
|
|
|
|
#define TYPE_CMYKA_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(0))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_CMYKA_HALF_FLT
|
|
|
|
|
#define TYPE_CMYKA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(2))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_CMYKA_FLT
|
|
|
|
|
#define TYPE_CMYKA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(4))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TYPE_CMYKA_16
|
|
|
|
|
#define TYPE_CMYKA_16 (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(2))
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-12-15 06:16:38 +08:00
|
|
|
|
|
2014-02-06 22:53:37 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* SECTION: gimpcolorprofile
|
|
|
|
|
* @title: GimpColorProfile
|
2014-02-06 22:53:37 +08:00
|
|
|
|
* @short_description: Definitions and Functions relating to LCMS.
|
|
|
|
|
*
|
|
|
|
|
* Definitions and Functions relating to LCMS.
|
|
|
|
|
**/
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
|
|
|
|
* GimpColorProfile:
|
|
|
|
|
*
|
|
|
|
|
* Simply a typedef to #gpointer, but actually is a cmsHPROFILE. It's
|
|
|
|
|
* used in public GIMP APIs in order to avoid having to include LCMS
|
|
|
|
|
* headers.
|
|
|
|
|
**/
|
|
|
|
|
|
2014-04-11 02:41:32 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
struct _GimpColorProfile
|
2015-07-11 04:43:53 +08:00
|
|
|
|
{
|
2024-07-28 13:28:31 +08:00
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
cmsHPROFILE lcms_profile;
|
|
|
|
|
guint8 *data;
|
|
|
|
|
gsize length;
|
2015-07-12 20:08:42 +08:00
|
|
|
|
|
|
|
|
|
gchar *description;
|
|
|
|
|
gchar *manufacturer;
|
|
|
|
|
gchar *model;
|
|
|
|
|
gchar *copyright;
|
|
|
|
|
gchar *label;
|
|
|
|
|
gchar *summary;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_color_profile_finalize (GObject *object);
|
|
|
|
|
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
G_DEFINE_TYPE (GimpColorProfile, gimp_color_profile, G_TYPE_OBJECT)
|
2015-07-11 04:43:53 +08:00
|
|
|
|
|
|
|
|
|
#define parent_class gimp_color_profile_parent_class
|
|
|
|
|
|
|
|
|
|
|
2017-09-03 02:29:29 +08:00
|
|
|
|
#define GIMP_COLOR_PROFILE_ERROR gimp_color_profile_error_quark ()
|
|
|
|
|
|
2014-03-16 07:06:31 +08:00
|
|
|
|
static GQuark
|
2015-06-03 15:41:23 +08:00
|
|
|
|
gimp_color_profile_error_quark (void)
|
2014-03-16 07:06:31 +08:00
|
|
|
|
{
|
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (quark == 0))
|
2015-06-03 15:41:23 +08:00
|
|
|
|
quark = g_quark_from_static_string ("gimp-color-profile-error-quark");
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
|
|
|
|
return quark;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_color_profile_class_init (GimpColorProfileClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gimp_color_profile_finalize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_color_profile_init (GimpColorProfile *profile)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_color_profile_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GimpColorProfile *profile = GIMP_COLOR_PROFILE (object);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
g_clear_pointer (&profile->lcms_profile, cmsCloseProfile);
|
2017-09-03 21:14:51 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
g_clear_pointer (&profile->data, g_free);
|
|
|
|
|
profile->length = 0;
|
2017-09-03 21:14:51 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
g_clear_pointer (&profile->description, g_free);
|
|
|
|
|
g_clear_pointer (&profile->manufacturer, g_free);
|
|
|
|
|
g_clear_pointer (&profile->model, g_free);
|
|
|
|
|
g_clear_pointer (&profile->copyright, g_free);
|
|
|
|
|
g_clear_pointer (&profile->label, g_free);
|
|
|
|
|
g_clear_pointer (&profile->summary, g_free);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* gimp_color_profile_new_from_file:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @file: a #GFile
|
|
|
|
|
* @error: return location for #GError
|
|
|
|
|
*
|
|
|
|
|
* This function opens an ICC color profile from @file.
|
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable): the #GimpColorProfile, or %NULL. On error, %NULL is
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* returned and @error is set.
|
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *
|
|
|
|
|
gimp_color_profile_new_from_file (GFile *file,
|
|
|
|
|
GError **error)
|
2014-03-16 07:06:31 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *profile = NULL;
|
|
|
|
|
cmsHPROFILE lcms_profile = NULL;
|
|
|
|
|
guint8 *data = NULL;
|
|
|
|
|
gsize length = 0;
|
2014-07-05 05:57:27 +08:00
|
|
|
|
gchar *path;
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
2014-03-16 07:06:31 +08:00
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
path = g_file_get_path (file);
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
if (path)
|
|
|
|
|
{
|
2016-05-05 00:58:37 +08:00
|
|
|
|
GMappedFile *mapped;
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
mapped = g_mapped_file_new (path, FALSE, error);
|
2016-05-05 00:58:37 +08:00
|
|
|
|
g_free (path);
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
if (! mapped)
|
|
|
|
|
return NULL;
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2014-07-05 05:57:27 +08:00
|
|
|
|
length = g_mapped_file_get_length (mapped);
|
2021-08-26 23:18:32 +08:00
|
|
|
|
data = g_memdup2 (g_mapped_file_get_contents (mapped), length);
|
2014-07-05 05:57:27 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
lcms_profile = cmsOpenProfileFromMem (data, length);
|
2014-07-05 05:57:27 +08:00
|
|
|
|
|
|
|
|
|
g_mapped_file_unref (mapped);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GFileInfo *info;
|
|
|
|
|
|
|
|
|
|
info = g_file_query_info (file,
|
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
|
NULL, error);
|
|
|
|
|
if (info)
|
|
|
|
|
{
|
|
|
|
|
GInputStream *input;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
|
2023-09-19 20:38:42 +08:00
|
|
|
|
length = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
2015-07-11 04:43:53 +08:00
|
|
|
|
data = g_malloc (length);
|
2014-07-05 05:57:27 +08:00
|
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
|
|
|
|
|
|
input = G_INPUT_STREAM (g_file_read (file, NULL, error));
|
|
|
|
|
|
|
|
|
|
if (input)
|
|
|
|
|
{
|
|
|
|
|
gsize bytes_read;
|
|
|
|
|
|
|
|
|
|
if (g_input_stream_read_all (input, data, length,
|
|
|
|
|
&bytes_read, NULL, error) &&
|
|
|
|
|
bytes_read == length)
|
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
lcms_profile = cmsOpenProfileFromMem (data, length);
|
2014-07-05 05:57:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (input);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
if (lcms_profile)
|
|
|
|
|
{
|
|
|
|
|
profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
profile->lcms_profile = lcms_profile;
|
|
|
|
|
profile->data = data;
|
|
|
|
|
profile->length = length;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (data)
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
|
|
if (error && *error == NULL)
|
|
|
|
|
{
|
2017-09-03 02:29:29 +08:00
|
|
|
|
g_set_error (error, GIMP_COLOR_PROFILE_ERROR, 0,
|
2015-07-11 04:43:53 +08:00
|
|
|
|
_("'%s' does not appear to be an ICC color profile"),
|
|
|
|
|
gimp_file_get_utf8_name (file));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* gimp_color_profile_new_from_icc_profile:
|
2020-05-04 08:10:55 +08:00
|
|
|
|
* @data: (array length=length): The memory containing an ICC profile
|
2018-04-19 02:57:03 +08:00
|
|
|
|
* @length: length of the profile in memory, in bytes
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @error: return location for #GError
|
|
|
|
|
*
|
|
|
|
|
* This function opens an ICC color profile from memory. On error,
|
|
|
|
|
* %NULL is returned and @error is set.
|
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable): the #GimpColorProfile, or %NULL.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *
|
|
|
|
|
gimp_color_profile_new_from_icc_profile (const guint8 *data,
|
|
|
|
|
gsize length,
|
|
|
|
|
GError **error)
|
2014-03-16 07:06:31 +08:00
|
|
|
|
{
|
2018-07-06 08:34:15 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = 0;
|
|
|
|
|
GimpColorProfile *profile = NULL;
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2018-07-06 08:34:15 +08:00
|
|
|
|
g_return_val_if_fail (data != NULL || length == 0, NULL);
|
2014-03-16 07:06:31 +08:00
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2018-07-06 08:34:15 +08:00
|
|
|
|
if (length > 0)
|
|
|
|
|
lcms_profile = cmsOpenProfileFromMem (data, length);
|
2015-07-11 04:43:53 +08:00
|
|
|
|
|
|
|
|
|
if (lcms_profile)
|
|
|
|
|
{
|
|
|
|
|
profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
profile->lcms_profile = lcms_profile;
|
|
|
|
|
profile->data = g_memdup2 (data, length);
|
|
|
|
|
profile->length = length;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-03 02:29:29 +08:00
|
|
|
|
g_set_error_literal (error, GIMP_COLOR_PROFILE_ERROR, 0,
|
2015-07-11 04:43:53 +08:00
|
|
|
|
_("Data does not appear to be an ICC color profile"));
|
|
|
|
|
}
|
2014-03-16 07:06:31 +08:00
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* gimp_color_profile_new_from_lcms_profile:
|
|
|
|
|
* @lcms_profile: an LCMS cmsHPROFILE pointer
|
|
|
|
|
* @error: return location for #GError
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* This function creates a GimpColorProfile from a cmsHPROFILE. On
|
|
|
|
|
* error, %NULL is returned and @error is set. The passed
|
|
|
|
|
* @lcms_profile pointer is not retained by the created
|
|
|
|
|
* #GimpColorProfile.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable): the #GimpColorProfile, or %NULL.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *
|
|
|
|
|
gimp_color_profile_new_from_lcms_profile (gpointer lcms_profile,
|
|
|
|
|
GError **error)
|
2014-04-10 22:30:04 +08:00
|
|
|
|
{
|
|
|
|
|
cmsUInt32Number size;
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (lcms_profile != NULL, NULL);
|
2014-04-10 22:30:04 +08:00
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
if (cmsSaveProfileToMem (lcms_profile, NULL, &size))
|
2014-04-10 22:30:04 +08:00
|
|
|
|
{
|
|
|
|
|
guint8 *data = g_malloc (size);
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
if (cmsSaveProfileToMem (lcms_profile, data, &size))
|
2014-04-10 22:30:04 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gsize length = size;
|
|
|
|
|
|
|
|
|
|
lcms_profile = cmsOpenProfileFromMem (data, length);
|
|
|
|
|
|
|
|
|
|
if (lcms_profile)
|
|
|
|
|
{
|
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
|
|
|
|
|
profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
profile->lcms_profile = lcms_profile;
|
|
|
|
|
profile->data = data;
|
|
|
|
|
profile->length = length;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
2014-04-10 22:30:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (data);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-03 02:29:29 +08:00
|
|
|
|
g_set_error_literal (error, GIMP_COLOR_PROFILE_ERROR, 0,
|
2014-04-10 22:30:04 +08:00
|
|
|
|
_("Could not save color profile to memory"));
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-05 02:40:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_save_to_file:
|
2017-06-04 03:03:25 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
* @file: a #GFile
|
|
|
|
|
* @error: return location for #GError
|
2016-05-05 02:40:04 +08:00
|
|
|
|
*
|
|
|
|
|
* This function saves @profile to @file as ICC profile.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE on success, %FALSE if an error occurred.
|
2016-05-05 02:40:04 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gimp_color_profile_save_to_file (GimpColorProfile *profile,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), FALSE);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return g_file_replace_contents (file,
|
2024-07-28 13:28:31 +08:00
|
|
|
|
(const gchar *) profile->data,
|
|
|
|
|
profile->length,
|
2016-05-05 02:40:04 +08:00
|
|
|
|
NULL, FALSE,
|
|
|
|
|
G_FILE_CREATE_NONE,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* gimp_color_profile_get_icc_profile:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
2020-05-04 08:10:55 +08:00
|
|
|
|
* @length: (out): return location for the number of bytes
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-07-11 04:43:53 +08:00
|
|
|
|
* This function returns @profile as ICC profile data. The returned
|
|
|
|
|
* memory belongs to @profile and must not be modified or freed.
|
|
|
|
|
*
|
2020-05-04 08:10:55 +08:00
|
|
|
|
* Returns: (array length=length): a pointer to the IIC profile data.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
const guint8 *
|
|
|
|
|
gimp_color_profile_get_icc_profile (GimpColorProfile *profile,
|
|
|
|
|
gsize *length)
|
2015-05-06 22:28:45 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
g_return_val_if_fail (length != NULL, NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
*length = profile->length;
|
2015-05-06 22:28:45 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->data;
|
2015-07-11 04:43:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_get_lcms_profile:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
|
|
|
|
* This function returns @profile's cmsHPROFILE. The returned
|
|
|
|
|
* value belongs to @profile and must not be modified or freed.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a pointer to the cmsHPROFILE.
|
2015-07-11 04:43:53 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
gpointer
|
|
|
|
|
gimp_color_profile_get_lcms_profile (GimpColorProfile *profile)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->lcms_profile;
|
2015-05-06 22:28:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-15 01:37:07 +08:00
|
|
|
|
static gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_info (GimpColorProfile *profile,
|
|
|
|
|
cmsInfoType info)
|
2014-03-14 08:44:27 +08:00
|
|
|
|
{
|
|
|
|
|
cmsUInt32Number size;
|
2014-03-15 01:37:07 +08:00
|
|
|
|
gchar *text = NULL;
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
size = cmsGetProfileInfoASCII (profile->lcms_profile, info,
|
2014-03-14 08:44:27 +08:00
|
|
|
|
"en", "US", NULL, 0);
|
|
|
|
|
if (size > 0)
|
|
|
|
|
{
|
|
|
|
|
gchar *data = g_new (gchar, size + 1);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
size = cmsGetProfileInfoASCII (profile->lcms_profile, info,
|
2014-03-14 08:44:27 +08:00
|
|
|
|
"en", "US", data, size);
|
|
|
|
|
if (size > 0)
|
2014-03-15 01:37:07 +08:00
|
|
|
|
text = gimp_any_to_utf8 (data, -1, NULL);
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
|
|
|
|
g_free (data);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-15 01:37:07 +08:00
|
|
|
|
return text;
|
2014-03-14 08:44:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_description:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a string containing @profile's description. The
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* returned value belongs to @profile and must not be
|
|
|
|
|
* modified or freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_description (GimpColorProfile *profile)
|
2014-03-14 08:44:27 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->description)
|
|
|
|
|
profile->description =
|
2015-07-12 20:08:42 +08:00
|
|
|
|
gimp_color_profile_get_info (profile, cmsInfoDescription);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->description;
|
2014-03-15 01:37:07 +08:00
|
|
|
|
}
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_manufacturer:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a string containing @profile's manufacturer. The
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* returned value belongs to @profile and must not be
|
|
|
|
|
* modified or freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_manufacturer (GimpColorProfile *profile)
|
2014-03-15 01:37:07 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->manufacturer)
|
|
|
|
|
profile->manufacturer =
|
2015-07-12 20:08:42 +08:00
|
|
|
|
gimp_color_profile_get_info (profile, cmsInfoManufacturer);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->manufacturer;
|
2014-03-15 01:37:07 +08:00
|
|
|
|
}
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_model:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a string containing @profile's model. The returned
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* value belongs to @profile and must not be modified or
|
|
|
|
|
* freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_model (GimpColorProfile *profile)
|
2014-03-15 01:37:07 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->model)
|
|
|
|
|
profile->model =
|
2015-07-12 20:08:42 +08:00
|
|
|
|
gimp_color_profile_get_info (profile, cmsInfoModel);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->model;
|
2014-03-15 01:37:07 +08:00
|
|
|
|
}
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_copyright:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a string containing @profile's copyright. The
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* returned value belongs to @profile and must not be
|
|
|
|
|
* modified or freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_copyright (GimpColorProfile *profile)
|
2014-03-15 01:37:07 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->copyright)
|
|
|
|
|
profile->copyright =
|
2015-07-12 20:08:42 +08:00
|
|
|
|
gimp_color_profile_get_info (profile, cmsInfoCopyright);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->copyright;
|
2014-03-14 08:44:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_label:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* This function returns a string containing @profile's "title", a
|
|
|
|
|
* string that can be used to label the profile in a user interface.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-08-23 03:59:30 +08:00
|
|
|
|
* Unlike gimp_color_profile_get_description(), this function always
|
2016-05-05 00:58:37 +08:00
|
|
|
|
* returns a string (as a fallback, it returns "(unnamed profile)").
|
2015-08-23 03:59:30 +08:00
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the @profile's label. The returned value belongs to
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* @profile and must not be modified or freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_label (GimpColorProfile *profile)
|
2014-03-30 09:12:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
2014-03-30 09:12:42 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->label)
|
2014-03-30 09:12:42 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *label = gimp_color_profile_get_description (profile);
|
2014-03-30 09:12:42 +08:00
|
|
|
|
|
2015-07-12 20:08:42 +08:00
|
|
|
|
if (! label || ! strlen (label))
|
|
|
|
|
label = _("(unnamed profile)");
|
2014-03-30 09:12:42 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
profile->label = g_strdup (label);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
}
|
2014-03-30 09:12:42 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->label;
|
2014-03-30 09:12:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_get_summary:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* This function return a string containing a multi-line summary of
|
|
|
|
|
* @profile's description, model, manufacturer and copyright, to be
|
2018-04-19 02:57:03 +08:00
|
|
|
|
* used as detailed information about the profile in a user
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* interface.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the @profile's summary. The returned value belongs to
|
2015-07-12 20:08:42 +08:00
|
|
|
|
* @profile and must not be modified or freed.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2015-07-12 20:08:42 +08:00
|
|
|
|
const gchar *
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_get_summary (GimpColorProfile *profile)
|
2014-03-14 08:44:27 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
if (! profile->summary)
|
2014-03-14 08:44:27 +08:00
|
|
|
|
{
|
2015-07-12 20:08:42 +08:00
|
|
|
|
GString *string = g_string_new (NULL);
|
|
|
|
|
const gchar *text;
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-07-12 20:08:42 +08:00
|
|
|
|
text = gimp_color_profile_get_description (profile);
|
|
|
|
|
if (text)
|
|
|
|
|
g_string_append (string, text);
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-07-12 20:08:42 +08:00
|
|
|
|
text = gimp_color_profile_get_model (profile);
|
|
|
|
|
if (text)
|
|
|
|
|
{
|
|
|
|
|
if (string->len > 0)
|
|
|
|
|
g_string_append (string, "\n");
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-08-23 03:59:30 +08:00
|
|
|
|
g_string_append_printf (string, _("Model: %s"), text);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
}
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-07-12 20:08:42 +08:00
|
|
|
|
text = gimp_color_profile_get_manufacturer (profile);
|
|
|
|
|
if (text)
|
|
|
|
|
{
|
|
|
|
|
if (string->len > 0)
|
|
|
|
|
g_string_append (string, "\n");
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2015-08-23 03:59:30 +08:00
|
|
|
|
g_string_append_printf (string, _("Manufacturer: %s"), text);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = gimp_color_profile_get_copyright (profile);
|
|
|
|
|
if (text)
|
|
|
|
|
{
|
|
|
|
|
if (string->len > 0)
|
|
|
|
|
g_string_append (string, "\n");
|
2015-08-23 03:59:30 +08:00
|
|
|
|
|
|
|
|
|
g_string_append_printf (string, _("Copyright: %s"), text);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
}
|
2014-03-14 08:44:27 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
profile->summary = g_string_free (string, FALSE);
|
2014-03-14 08:44:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return profile->summary;
|
2014-03-14 08:44:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_is_equal:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile1: a #GimpColorProfile
|
|
|
|
|
* @profile2: a #GimpColorProfile
|
|
|
|
|
*
|
|
|
|
|
* Compares two profiles.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE if the profiles are equal, %FALSE otherwise.
|
2015-05-07 08:00:33 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2014-03-29 17:40:47 +08:00
|
|
|
|
gboolean
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_is_equal (GimpColorProfile *profile1,
|
|
|
|
|
GimpColorProfile *profile2)
|
2014-03-29 17:40:47 +08:00
|
|
|
|
{
|
2015-07-11 05:06:53 +08:00
|
|
|
|
const gsize header_len = sizeof (cmsICCHeader);
|
2014-03-29 17:40:47 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile1), FALSE);
|
2017-11-03 15:11:47 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile2), FALSE);
|
2014-03-29 17:40:47 +08:00
|
|
|
|
|
2017-11-03 15:11:47 +08:00
|
|
|
|
return profile1 == profile2 ||
|
2024-07-28 13:28:31 +08:00
|
|
|
|
(profile1->length == profile2->length &&
|
|
|
|
|
memcmp (profile1->data + header_len,
|
|
|
|
|
profile2->data + header_len,
|
|
|
|
|
profile1->length - header_len) == 0);
|
2014-03-29 17:40:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 08:00:33 +08:00
|
|
|
|
/**
|
2015-06-03 15:41:23 +08:00
|
|
|
|
* gimp_color_profile_is_rgb:
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE if the profile's color space is RGB, %FALSE
|
2015-05-07 08:00:33 +08:00
|
|
|
|
* otherwise.
|
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-07 08:00:33 +08:00
|
|
|
|
**/
|
2014-03-16 04:46:02 +08:00
|
|
|
|
gboolean
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_is_rgb (GimpColorProfile *profile)
|
2014-03-16 04:46:02 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
2014-03-16 04:46:02 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return (cmsGetColorSpace (profile->lcms_profile) == cmsSigRgbData);
|
2014-03-16 04:46:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-13 21:33:51 +08:00
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_is_gray:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE if the profile's color space is grayscale, %FALSE
|
2015-12-13 21:33:51 +08:00
|
|
|
|
* otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gimp_color_profile_is_gray (GimpColorProfile *profile)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return (cmsGetColorSpace (profile->lcms_profile) == cmsSigGrayData);
|
2015-12-13 21:33:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_is_cmyk:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE if the profile's color space is CMYK, %FALSE
|
2015-12-13 21:33:51 +08:00
|
|
|
|
* otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gimp_color_profile_is_cmyk (GimpColorProfile *profile)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
return (cmsGetColorSpace (profile->lcms_profile) == cmsSigCmykData);
|
2015-12-13 21:33:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-23 08:29:17 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_is_linear:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
|
|
|
|
* This function determines is the ICC profile represented by a GimpColorProfile
|
|
|
|
|
* is a linear RGB profile or not, some profiles that are LUTs though linear
|
|
|
|
|
* will also return FALSE;
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: %TRUE if the profile is a matrix shaping profile with linear
|
2015-11-23 08:29:17 +08:00
|
|
|
|
* TRCs, %FALSE otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
gimp_color_profile_is_linear (GimpColorProfile *profile)
|
|
|
|
|
{
|
2015-12-13 21:33:51 +08:00
|
|
|
|
cmsHPROFILE prof;
|
2015-11-23 08:29:17 +08:00
|
|
|
|
cmsToneCurve *curve;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
prof = profile->lcms_profile;
|
2015-11-23 08:29:17 +08:00
|
|
|
|
|
|
|
|
|
if (! cmsIsMatrixShaper (prof))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (cmsIsCLUT (prof, INTENT_PERCEPTUAL, LCMS_USED_AS_INPUT))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (cmsIsCLUT (prof, INTENT_PERCEPTUAL, LCMS_USED_AS_OUTPUT))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2015-12-13 21:33:51 +08:00
|
|
|
|
if (gimp_color_profile_is_rgb (profile))
|
|
|
|
|
{
|
|
|
|
|
curve = cmsReadTag(prof, cmsSigRedTRCTag);
|
|
|
|
|
if (curve == NULL || ! cmsIsToneCurveLinear (curve))
|
|
|
|
|
return FALSE;
|
2015-11-23 08:29:17 +08:00
|
|
|
|
|
2015-12-13 21:33:51 +08:00
|
|
|
|
curve = cmsReadTag (prof, cmsSigGreenTRCTag);
|
|
|
|
|
if (curve == NULL || ! cmsIsToneCurveLinear (curve))
|
|
|
|
|
return FALSE;
|
2015-11-23 08:29:17 +08:00
|
|
|
|
|
2015-12-13 21:33:51 +08:00
|
|
|
|
curve = cmsReadTag (prof, cmsSigBlueTRCTag);
|
|
|
|
|
if (curve == NULL || ! cmsIsToneCurveLinear (curve))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (gimp_color_profile_is_gray (profile))
|
|
|
|
|
{
|
|
|
|
|
curve = cmsReadTag(prof, cmsSigGrayTRCTag);
|
|
|
|
|
if (curve == NULL || ! cmsIsToneCurveLinear (curve))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2015-11-23 08:29:17 +08:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-15 07:06:47 +08:00
|
|
|
|
static void
|
2015-06-03 15:41:23 +08:00
|
|
|
|
gimp_color_profile_set_tag (cmsHPROFILE profile,
|
|
|
|
|
cmsTagSignature sig,
|
|
|
|
|
const gchar *tag)
|
2014-03-15 07:06:47 +08:00
|
|
|
|
{
|
|
|
|
|
cmsMLU *mlu;
|
|
|
|
|
|
|
|
|
|
mlu = cmsMLUalloc (NULL, 1);
|
|
|
|
|
cmsMLUsetASCII (mlu, "en", "US", tag);
|
|
|
|
|
cmsWriteTag (profile, sig, mlu);
|
|
|
|
|
cmsMLUfree (mlu);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-22 05:29:39 +08:00
|
|
|
|
static gboolean
|
|
|
|
|
gimp_color_profile_get_rgb_matrix_colorants (GimpColorProfile *profile,
|
|
|
|
|
GimpMatrix3 *matrix)
|
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE lcms_profile;
|
|
|
|
|
cmsCIEXYZ *red;
|
|
|
|
|
cmsCIEXYZ *green;
|
|
|
|
|
cmsCIEXYZ *blue;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
lcms_profile = profile->lcms_profile;
|
2015-08-22 05:29:39 +08:00
|
|
|
|
|
|
|
|
|
red = cmsReadTag (lcms_profile, cmsSigRedColorantTag);
|
|
|
|
|
green = cmsReadTag (lcms_profile, cmsSigGreenColorantTag);
|
|
|
|
|
blue = cmsReadTag (lcms_profile, cmsSigBlueColorantTag);
|
|
|
|
|
|
|
|
|
|
if (red && green && blue)
|
|
|
|
|
{
|
|
|
|
|
if (matrix)
|
|
|
|
|
{
|
|
|
|
|
matrix->coeff[0][0] = red->X;
|
|
|
|
|
matrix->coeff[0][1] = red->Y;
|
|
|
|
|
matrix->coeff[0][2] = red->Z;
|
|
|
|
|
|
|
|
|
|
matrix->coeff[1][0] = green->X;
|
|
|
|
|
matrix->coeff[1][1] = green->Y;
|
|
|
|
|
matrix->coeff[1][2] = green->Z;
|
|
|
|
|
|
|
|
|
|
matrix->coeff[2][0] = blue->X;
|
2015-10-22 02:25:06 +08:00
|
|
|
|
matrix->coeff[2][1] = blue->Y;
|
|
|
|
|
matrix->coeff[2][2] = blue->Z;
|
2015-08-22 05:29:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-31 21:44:07 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_color_profile_make_tag (cmsHPROFILE profile,
|
|
|
|
|
cmsTagSignature sig,
|
|
|
|
|
const gchar *gimp_tag,
|
|
|
|
|
const gchar *gimp_prefix,
|
|
|
|
|
const gchar *gimp_prefix_alt,
|
|
|
|
|
const gchar *original_tag)
|
|
|
|
|
{
|
|
|
|
|
if (! original_tag || ! strlen (original_tag) ||
|
|
|
|
|
! strcmp (original_tag, gimp_tag))
|
|
|
|
|
{
|
|
|
|
|
/* if there is no original tag (or it is the same as the new
|
|
|
|
|
* tag), just use the new tag
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, sig, gimp_tag);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* otherwise prefix the existing tag with a gimp prefix
|
|
|
|
|
* indicating that the profile has been generated
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (g_str_has_prefix (original_tag, gimp_prefix))
|
|
|
|
|
{
|
|
|
|
|
/* don't add multiple GIMP prefixes */
|
|
|
|
|
gimp_color_profile_set_tag (profile, sig, original_tag);
|
|
|
|
|
}
|
|
|
|
|
else if (gimp_prefix_alt &&
|
|
|
|
|
g_str_has_prefix (original_tag, gimp_prefix_alt))
|
|
|
|
|
{
|
|
|
|
|
/* replace GIMP prefix_alt by prefix */
|
|
|
|
|
gchar *new_tag = g_strconcat (gimp_prefix,
|
|
|
|
|
original_tag + strlen (gimp_prefix_alt),
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, sig, new_tag);
|
|
|
|
|
g_free (new_tag);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gchar *new_tag = g_strconcat (gimp_prefix,
|
|
|
|
|
original_tag,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, sig, new_tag);
|
|
|
|
|
g_free (new_tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-22 05:29:39 +08:00
|
|
|
|
static GimpColorProfile *
|
2015-10-21 02:12:18 +08:00
|
|
|
|
gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
|
|
|
|
|
gboolean linear)
|
2015-08-22 05:29:39 +08:00
|
|
|
|
{
|
|
|
|
|
GimpColorProfile *new_profile;
|
|
|
|
|
cmsHPROFILE target_profile;
|
2017-07-14 19:10:46 +08:00
|
|
|
|
GimpMatrix3 matrix = { { { 0, } } };
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsCIEXYZ *whitepoint;
|
|
|
|
|
cmsToneCurve *curve;
|
2015-08-22 05:29:39 +08:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
2015-12-14 06:36:31 +08:00
|
|
|
|
if (gimp_color_profile_is_rgb (profile))
|
|
|
|
|
{
|
|
|
|
|
if (! gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (! gimp_color_profile_is_gray (profile))
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2015-08-22 05:29:39 +08:00
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
whitepoint = cmsReadTag (profile->lcms_profile,
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsSigMediaWhitePointTag);
|
|
|
|
|
|
2015-08-22 05:29:39 +08:00
|
|
|
|
target_profile = cmsCreateProfilePlaceholder (0);
|
|
|
|
|
|
|
|
|
|
cmsSetProfileVersion (target_profile, 4.3);
|
|
|
|
|
cmsSetDeviceClass (target_profile, cmsSigDisplayClass);
|
|
|
|
|
cmsSetPCS (target_profile, cmsSigXYZData);
|
2015-10-19 07:14:35 +08:00
|
|
|
|
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigMediaWhitePointTag, whitepoint);
|
|
|
|
|
|
|
|
|
|
if (linear)
|
|
|
|
|
{
|
|
|
|
|
/* linear light */
|
|
|
|
|
curve = cmsBuildGamma (NULL, 1.00);
|
2015-08-22 05:29:39 +08:00
|
|
|
|
|
2019-05-31 21:44:07 +08:00
|
|
|
|
gimp_color_profile_make_tag (target_profile, cmsSigProfileDescriptionTag,
|
|
|
|
|
"linear TRC from unnamed profile",
|
|
|
|
|
"linear TRC from ",
|
|
|
|
|
"sRGB TRC from ",
|
|
|
|
|
gimp_color_profile_get_description (profile));
|
2015-10-19 07:14:35 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmsFloat64Number srgb_parameters[5] =
|
|
|
|
|
{ 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
|
|
|
|
|
|
|
|
|
|
/* sRGB curve */
|
|
|
|
|
curve = cmsBuildParametricToneCurve (NULL, 4, srgb_parameters);
|
|
|
|
|
|
2019-05-31 21:44:07 +08:00
|
|
|
|
gimp_color_profile_make_tag (target_profile, cmsSigProfileDescriptionTag,
|
|
|
|
|
"sRGB TRC from unnamed profile",
|
|
|
|
|
"sRGB TRC from ",
|
|
|
|
|
"linear TRC from ",
|
|
|
|
|
gimp_color_profile_get_description (profile));
|
2015-10-19 07:14:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 06:36:31 +08:00
|
|
|
|
if (gimp_color_profile_is_rgb (profile))
|
|
|
|
|
{
|
|
|
|
|
cmsCIEXYZ red;
|
|
|
|
|
cmsCIEXYZ green;
|
|
|
|
|
cmsCIEXYZ blue;
|
|
|
|
|
|
|
|
|
|
cmsSetColorSpace (target_profile, cmsSigRgbData);
|
|
|
|
|
|
|
|
|
|
red.X = matrix.coeff[0][0];
|
|
|
|
|
red.Y = matrix.coeff[0][1];
|
|
|
|
|
red.Z = matrix.coeff[0][2];
|
|
|
|
|
|
|
|
|
|
green.X = matrix.coeff[1][0];
|
|
|
|
|
green.Y = matrix.coeff[1][1];
|
|
|
|
|
green.Z = matrix.coeff[1][2];
|
|
|
|
|
|
|
|
|
|
blue.X = matrix.coeff[2][0];
|
|
|
|
|
blue.Y = matrix.coeff[2][1];
|
|
|
|
|
blue.Z = matrix.coeff[2][2];
|
|
|
|
|
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigRedColorantTag, &red);
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigGreenColorantTag, &green);
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigBlueColorantTag, &blue);
|
|
|
|
|
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigGreenTRCTag, curve);
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigBlueTRCTag, curve);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmsSetColorSpace (target_profile, cmsSigGrayData);
|
|
|
|
|
|
|
|
|
|
cmsWriteTag (target_profile, cmsSigGrayTRCTag, curve);
|
|
|
|
|
}
|
2015-10-19 07:14:35 +08:00
|
|
|
|
|
|
|
|
|
cmsFreeToneCurve (curve);
|
2015-08-22 05:29:39 +08:00
|
|
|
|
|
2019-05-31 21:44:07 +08:00
|
|
|
|
gimp_color_profile_make_tag (target_profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP",
|
|
|
|
|
"GIMP from ", NULL,
|
|
|
|
|
gimp_color_profile_get_manufacturer (profile));
|
|
|
|
|
gimp_color_profile_make_tag (target_profile, cmsSigDeviceModelDescTag,
|
|
|
|
|
"Generated by GIMP",
|
|
|
|
|
"GIMP from ", NULL,
|
|
|
|
|
gimp_color_profile_get_model (profile));
|
|
|
|
|
gimp_color_profile_make_tag (target_profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain",
|
|
|
|
|
"GIMP from ", NULL,
|
|
|
|
|
gimp_color_profile_get_copyright (profile));
|
2015-10-21 02:12:18 +08:00
|
|
|
|
|
2015-08-22 05:29:39 +08:00
|
|
|
|
new_profile = gimp_color_profile_new_from_lcms_profile (target_profile, NULL);
|
|
|
|
|
|
|
|
|
|
cmsCloseProfile (target_profile);
|
|
|
|
|
|
|
|
|
|
return new_profile;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 02:12:18 +08:00
|
|
|
|
/**
|
2016-04-10 00:47:51 +08:00
|
|
|
|
* gimp_color_profile_new_srgb_trc_from_color_profile:
|
2015-10-21 02:12:18 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
|
|
|
|
* This function creates a new RGB #GimpColorProfile with a sRGB gamma
|
|
|
|
|
* TRC and @profile's RGB chromacities and whitepoint.
|
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable) (transfer full): the new #GimpColorProfile, or %NULL if
|
2019-08-01 07:52:07 +08:00
|
|
|
|
* @profile is not an RGB profile or not matrix-based.
|
2015-10-21 02:12:18 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_srgb_trc_from_color_profile (GimpColorProfile *profile)
|
2015-10-21 02:12:18 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_color_profile (profile, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-04-10 00:47:51 +08:00
|
|
|
|
* gimp_color_profile_new_linear_from_color_profile:
|
2015-10-21 02:12:18 +08:00
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
*
|
|
|
|
|
* This function creates a new RGB #GimpColorProfile with a linear TRC
|
|
|
|
|
* and @profile's RGB chromacities and whitepoint.
|
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable) (transfer full): the new #GimpColorProfile, or %NULL if
|
2019-08-01 07:52:07 +08:00
|
|
|
|
* @profile is not an RGB profile or not matrix-based.
|
2015-10-21 02:12:18 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_linear_from_color_profile (GimpColorProfile *profile)
|
2015-10-21 02:12:18 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_color_profile (profile, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
static cmsHPROFILE *
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_srgb_internal (void)
|
2014-02-06 22:53:37 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
cmsHPROFILE profile;
|
2014-02-10 22:42:39 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
/* white point is D65 from the sRGB specs */
|
|
|
|
|
cmsCIExyY whitepoint = { 0.3127, 0.3290, 1.0 };
|
|
|
|
|
|
|
|
|
|
/* primaries are ITU‐R BT.709‐5 (xYY), which are also the primaries
|
|
|
|
|
* from the sRGB specs, modified to properly account for hexadecimal
|
|
|
|
|
* quantization during the profile making process.
|
|
|
|
|
*/
|
|
|
|
|
cmsCIExyYTRIPLE primaries =
|
2014-02-06 22:53:37 +08:00
|
|
|
|
{
|
2015-10-19 07:14:35 +08:00
|
|
|
|
/* R { 0.6400, 0.3300, 1.0 }, */
|
|
|
|
|
/* G { 0.3000, 0.6000, 1.0 }, */
|
|
|
|
|
/* B { 0.1500, 0.0600, 1.0 } */
|
|
|
|
|
/* R */ { 0.639998686, 0.330010138, 1.0 },
|
|
|
|
|
/* G */ { 0.300003784, 0.600003357, 1.0 },
|
|
|
|
|
/* B */ { 0.150002046, 0.059997204, 1.0 }
|
2014-02-06 22:53:37 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cmsFloat64Number srgb_parameters[5] =
|
|
|
|
|
{ 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
|
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsToneCurve *curve[3];
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
/* sRGB curve */
|
|
|
|
|
curve[0] = curve[1] = curve[2] = cmsBuildParametricToneCurve (NULL, 4,
|
|
|
|
|
srgb_parameters);
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
profile = cmsCreateRGBProfile (&whitepoint, &primaries, curve);
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsFreeToneCurve (curve[0]);
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
2015-06-03 15:41:23 +08:00
|
|
|
|
"GIMP built-in sRGB");
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
2015-06-03 15:41:23 +08:00
|
|
|
|
"GIMP");
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
2015-06-03 15:41:23 +08:00
|
|
|
|
"sRGB");
|
2015-07-11 04:43:53 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
2015-06-03 15:41:23 +08:00
|
|
|
|
"Public Domain");
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-05-31 08:47:24 +08:00
|
|
|
|
/* The following line produces a V2 profile with a point curve TRC.
|
2014-02-10 22:42:39 +08:00
|
|
|
|
* Profiles with point curve TRCs can't be used in LCMS2 unbounded
|
|
|
|
|
* mode ICC profile conversions. A V2 profile might be appropriate
|
|
|
|
|
* for embedding in sRGB images saved to disk, if the image is to be
|
|
|
|
|
* opened by an image editing application that doesn't understand V4
|
|
|
|
|
* profiles.
|
|
|
|
|
*
|
|
|
|
|
* cmsSetProfileVersion (srgb_profile, 2.1);
|
2015-05-31 08:47:24 +08:00
|
|
|
|
*/
|
2014-02-06 22:53:37 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
return profile;
|
2014-02-06 22:53:37 +08:00
|
|
|
|
}
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-12-16 03:42:21 +08:00
|
|
|
|
* gimp_color_profile_new_rgb_srgb:
|
2014-04-10 22:30:04 +08:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* The actual primaries in the sRGB specification are
|
|
|
|
|
* red xy: {0.6400, 0.3300, 1.0}
|
|
|
|
|
* green xy: {0.3000, 0.6000, 1.0}
|
|
|
|
|
* blue xy: {0.1500, 0.0600, 1.0}
|
|
|
|
|
*
|
|
|
|
|
* The sRGB primaries given below are "pre-quantized" to compensate
|
|
|
|
|
* for hexadecimal quantization during the profile-making process.
|
|
|
|
|
* Unless the profile-making code compensates for this quantization,
|
|
|
|
|
* the resulting profile's red, green, and blue colorants will deviate
|
|
|
|
|
* slightly from the correct XYZ values.
|
|
|
|
|
*
|
|
|
|
|
* LCMS2 doesn't compensate for hexadecimal quantization. The
|
|
|
|
|
* "pre-quantized" primaries below were back-calculated from the
|
|
|
|
|
* ArgyllCMS sRGB.icm profile. The resulting sRGB profile's colorants
|
|
|
|
|
* exactly matches the ArgyllCMS sRGB.icm profile colorants.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the sRGB #GimpColorProfile.
|
2014-04-10 22:30:04 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2014-04-10 22:30:04 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_srgb (void)
|
2014-04-10 22:30:04 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
static GimpColorProfile *profile = NULL;
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
2015-12-16 03:42:21 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_rgb_srgb_internal ();
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
2014-04-10 22:30:04 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
cmsCloseProfile (lcms_profile);
|
2014-04-10 22:30:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
2014-04-10 22:30:04 +08:00
|
|
|
|
}
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
static cmsHPROFILE
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_srgb_linear_internal (void)
|
2015-05-13 04:47:12 +08:00
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE profile;
|
|
|
|
|
|
|
|
|
|
/* white point is D65 from the sRGB specs */
|
|
|
|
|
cmsCIExyY whitepoint = { 0.3127, 0.3290, 1.0 };
|
|
|
|
|
|
|
|
|
|
/* primaries are ITU‐R BT.709‐5 (xYY), which are also the primaries
|
|
|
|
|
* from the sRGB specs, modified to properly account for hexadecimal
|
|
|
|
|
* quantization during the profile making process.
|
|
|
|
|
*/
|
|
|
|
|
cmsCIExyYTRIPLE primaries =
|
|
|
|
|
{
|
|
|
|
|
/* R { 0.6400, 0.3300, 1.0 }, */
|
|
|
|
|
/* G { 0.3000, 0.6000, 1.0 }, */
|
|
|
|
|
/* B { 0.1500, 0.0600, 1.0 } */
|
|
|
|
|
/* R */ { 0.639998686, 0.330010138, 1.0 },
|
|
|
|
|
/* G */ { 0.300003784, 0.600003357, 1.0 },
|
|
|
|
|
/* B */ { 0.150002046, 0.059997204, 1.0 }
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsToneCurve *curve[3];
|
|
|
|
|
|
2015-05-13 04:47:12 +08:00
|
|
|
|
/* linear light */
|
2015-10-19 07:14:35 +08:00
|
|
|
|
curve[0] = curve[1] = curve[2] = cmsBuildGamma (NULL, 1.0);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
profile = cmsCreateRGBProfile (&whitepoint, &primaries, curve);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsFreeToneCurve (curve[0]);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-06-03 15:41:23 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
2016-04-08 18:01:35 +08:00
|
|
|
|
"GIMP built-in Linear sRGB");
|
2015-06-03 15:41:23 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
2016-04-08 18:01:35 +08:00
|
|
|
|
"Linear sRGB");
|
2015-06-03 15:41:23 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain");
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-16 03:42:21 +08:00
|
|
|
|
* gimp_color_profile_new_rgb_srgb_linear:
|
2015-05-13 04:47:12 +08:00
|
|
|
|
*
|
|
|
|
|
* This function creates a profile for babl_model("RGB"). Please
|
2018-04-19 02:57:03 +08:00
|
|
|
|
* somebody write something smarter here.
|
2015-05-13 04:47:12 +08:00
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the linear RGB #GimpColorProfile.
|
2015-05-13 04:47:12 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-13 04:47:12 +08:00
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
|
GimpColorProfile *
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_srgb_linear (void)
|
2015-05-13 04:47:12 +08:00
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
|
static GimpColorProfile *profile = NULL;
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
2015-12-16 03:42:21 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_rgb_srgb_linear_internal ();
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
cmsCloseProfile (lcms_profile);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
2015-05-13 04:47:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 05:10:56 +08:00
|
|
|
|
static cmsHPROFILE *
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_adobe_internal (void)
|
2015-08-20 05:10:56 +08:00
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE profile;
|
2015-10-19 07:14:35 +08:00
|
|
|
|
|
|
|
|
|
/* white point is D65 from the sRGB specs */
|
|
|
|
|
cmsCIExyY whitepoint = { 0.3127, 0.3290, 1.0 };
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
|
|
|
|
/* AdobeRGB1998 and sRGB have the same white point.
|
|
|
|
|
*
|
|
|
|
|
* The primaries below are technically correct, but because of
|
|
|
|
|
* hexadecimal rounding these primaries don't make a profile that
|
|
|
|
|
* matches the original.
|
|
|
|
|
*
|
2015-10-19 07:14:35 +08:00
|
|
|
|
* cmsCIExyYTRIPLE primaries = {
|
2015-08-20 05:10:56 +08:00
|
|
|
|
* { 0.6400, 0.3300, 1.0 },
|
|
|
|
|
* { 0.2100, 0.7100, 1.0 },
|
|
|
|
|
* { 0.1500, 0.0600, 1.0 }
|
|
|
|
|
* };
|
|
|
|
|
*/
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsCIExyYTRIPLE primaries =
|
2015-08-20 05:10:56 +08:00
|
|
|
|
{
|
2015-10-19 07:14:35 +08:00
|
|
|
|
{ 0.639996511, 0.329996864, 1.0 },
|
|
|
|
|
{ 0.210005295, 0.710004866, 1.0 },
|
|
|
|
|
{ 0.149997606, 0.060003644, 1.0 }
|
2015-08-20 05:10:56 +08:00
|
|
|
|
};
|
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsToneCurve *curve[3];
|
|
|
|
|
|
|
|
|
|
/* gamma 2.2 */
|
|
|
|
|
curve[0] = curve[1] = curve[2] = cmsBuildGamma (NULL, 2.19921875);
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
profile = cmsCreateRGBProfile (&whitepoint, &primaries, curve);
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
2015-10-19 07:14:35 +08:00
|
|
|
|
cmsFreeToneCurve (curve[0]);
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
|
|
|
|
"Compatible with Adobe RGB (1998)");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
|
|
|
|
"Compatible with Adobe RGB (1998)");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain");
|
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-16 03:42:21 +08:00
|
|
|
|
* gimp_color_profile_new_rgb_adobe:
|
2015-08-20 05:10:56 +08:00
|
|
|
|
*
|
|
|
|
|
* This function creates a profile compatible with AbobeRGB (1998).
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the AdobeRGB-compatible #GimpColorProfile.
|
2015-08-20 05:10:56 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
2015-12-16 03:42:21 +08:00
|
|
|
|
gimp_color_profile_new_rgb_adobe (void)
|
2015-08-20 05:10:56 +08:00
|
|
|
|
{
|
|
|
|
|
static GimpColorProfile *profile = NULL;
|
|
|
|
|
|
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
2015-12-16 03:42:21 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_rgb_adobe_internal ();
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
cmsCloseProfile (lcms_profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cmsHPROFILE *
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_d65_gray_srgb_trc_internal (void)
|
2015-12-14 02:43:02 +08:00
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE profile;
|
|
|
|
|
|
2015-12-15 01:43:26 +08:00
|
|
|
|
/* white point is D65 from the sRGB specs */
|
|
|
|
|
cmsCIExyY whitepoint = { 0.3127, 0.3290, 1.0 };
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
cmsFloat64Number srgb_parameters[5] =
|
|
|
|
|
{ 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 };
|
|
|
|
|
|
|
|
|
|
cmsToneCurve *curve = cmsBuildParametricToneCurve (NULL, 4,
|
|
|
|
|
srgb_parameters);
|
|
|
|
|
|
|
|
|
|
profile = cmsCreateGrayProfile (&whitepoint, curve);
|
|
|
|
|
|
|
|
|
|
cmsFreeToneCurve (curve);
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
2016-04-08 19:15:58 +08:00
|
|
|
|
"GIMP built-in D65 Grayscale with sRGB TRC");
|
2015-12-14 02:43:02 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
2016-04-08 19:15:58 +08:00
|
|
|
|
"D65 Grayscale with sRGB TRC");
|
2015-12-14 02:43:02 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain");
|
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-04-10 00:47:51 +08:00
|
|
|
|
* gimp_color_profile_new_d65_gray_srgb_trc
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
|
|
|
|
* This function creates a grayscale #GimpColorProfile with an
|
2017-06-04 03:03:25 +08:00
|
|
|
|
* sRGB TRC. See gimp_color_profile_new_rgb_srgb().
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the sRGB-gamma grayscale #GimpColorProfile.
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_d65_gray_srgb_trc (void)
|
2015-12-14 02:43:02 +08:00
|
|
|
|
{
|
|
|
|
|
static GimpColorProfile *profile = NULL;
|
|
|
|
|
|
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
2016-04-10 00:47:51 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_d65_gray_srgb_trc_internal ();
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
|
|
|
|
|
|
|
|
|
cmsCloseProfile (lcms_profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cmsHPROFILE
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_d65_gray_linear_internal (void)
|
2015-12-14 02:43:02 +08:00
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE profile;
|
|
|
|
|
|
2015-12-15 01:43:26 +08:00
|
|
|
|
/* white point is D65 from the sRGB specs */
|
|
|
|
|
cmsCIExyY whitepoint = { 0.3127, 0.3290, 1.0 };
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
cmsToneCurve *curve = cmsBuildGamma (NULL, 1.0);
|
|
|
|
|
|
|
|
|
|
profile = cmsCreateGrayProfile (&whitepoint, curve);
|
|
|
|
|
|
|
|
|
|
cmsFreeToneCurve (curve);
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
2016-04-08 19:15:58 +08:00
|
|
|
|
"GIMP built-in D65 Linear Grayscale");
|
2015-12-14 02:43:02 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
2016-04-08 19:15:58 +08:00
|
|
|
|
"D65 Linear Grayscale");
|
2015-12-14 02:43:02 +08:00
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain");
|
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-04-10 00:47:51 +08:00
|
|
|
|
* gimp_color_profile_new_d65_gray_srgb_gray:
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
|
|
|
|
* This function creates a profile for babl_model("Y"). Please
|
2018-04-19 02:57:03 +08:00
|
|
|
|
* somebody write something smarter here.
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the linear grayscale #GimpColorProfile.
|
2015-12-14 02:43:02 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
2016-04-10 00:47:51 +08:00
|
|
|
|
gimp_color_profile_new_d65_gray_linear (void)
|
2015-12-14 02:43:02 +08:00
|
|
|
|
{
|
|
|
|
|
static GimpColorProfile *profile = NULL;
|
|
|
|
|
|
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
2016-04-10 00:47:51 +08:00
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_d65_gray_linear_internal ();
|
2015-12-14 02:43:02 +08:00
|
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
2015-08-20 05:10:56 +08:00
|
|
|
|
|
|
|
|
|
cmsCloseProfile (lcms_profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-21 05:01:17 +08:00
|
|
|
|
static cmsHPROFILE *
|
|
|
|
|
gimp_color_profile_new_d50_gray_lab_trc_internal (void)
|
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE profile;
|
|
|
|
|
|
|
|
|
|
/* white point is D50 from the ICC profile illuminant specs */
|
|
|
|
|
cmsCIExyY whitepoint = {0.345702915, 0.358538597, 1.0};
|
|
|
|
|
|
|
|
|
|
cmsFloat64Number lab_parameters[5] =
|
|
|
|
|
{ 3.0, 1.0 / 1.16, 0.16 / 1.16, 2700.0 / 24389.0, 0.08000 };
|
|
|
|
|
|
|
|
|
|
cmsToneCurve *curve = cmsBuildParametricToneCurve (NULL, 4,
|
|
|
|
|
lab_parameters);
|
|
|
|
|
|
|
|
|
|
profile = cmsCreateGrayProfile (&whitepoint, curve);
|
|
|
|
|
|
|
|
|
|
cmsFreeToneCurve (curve);
|
|
|
|
|
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
|
|
|
|
|
"GIMP built-in D50 Grayscale with LAB L TRC");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
|
|
|
|
|
"GIMP");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
|
|
|
|
|
"D50 Grayscale with LAB L TRC");
|
|
|
|
|
gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
|
|
|
|
|
"Public Domain");
|
|
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_new_d50_gray_lab_trc
|
|
|
|
|
*
|
|
|
|
|
* This function creates a grayscale #GimpColorProfile with the
|
|
|
|
|
* D50 ICC profile illuminant as the profile white point and the
|
|
|
|
|
* LAB companding curve as the TRC.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: a gray profile with the D50 ICC profile illuminant
|
2016-04-21 05:01:17 +08:00
|
|
|
|
* as the profile white point and the LAB companding curve as the TRC.
|
|
|
|
|
* as the TRC.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
GimpColorProfile *
|
|
|
|
|
gimp_color_profile_new_d50_gray_lab_trc (void)
|
|
|
|
|
{
|
|
|
|
|
static GimpColorProfile *profile = NULL;
|
|
|
|
|
|
|
|
|
|
const guint8 *data;
|
2023-08-18 18:54:06 +08:00
|
|
|
|
gsize length = 0;
|
2016-04-21 05:01:17 +08:00
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (profile == NULL))
|
|
|
|
|
{
|
|
|
|
|
cmsHPROFILE lcms_profile = gimp_color_profile_new_d50_gray_lab_trc_internal ();
|
|
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
|
|
|
|
|
|
|
|
|
|
cmsCloseProfile (lcms_profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &length);
|
|
|
|
|
|
|
|
|
|
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-16 20:06:32 +08:00
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_get_space:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
* @intent: a #GimpColorRenderingIntent
|
|
|
|
|
* @error: return location for #GError
|
|
|
|
|
*
|
|
|
|
|
* This function returns the #Babl space of @profile, for the
|
|
|
|
|
* specified @intent.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the new #Babl space.
|
2018-07-16 20:06:32 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10.6
|
|
|
|
|
**/
|
|
|
|
|
const Babl *
|
|
|
|
|
gimp_color_profile_get_space (GimpColorProfile *profile,
|
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const Babl *space;
|
|
|
|
|
const gchar *babl_error = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2024-07-28 13:28:31 +08:00
|
|
|
|
space = babl_space_from_icc ((const gchar *) profile->data,
|
|
|
|
|
profile->length,
|
2018-07-16 20:06:32 +08:00
|
|
|
|
(BablIccIntent) intent,
|
|
|
|
|
&babl_error);
|
|
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
|
g_set_error (error, GIMP_COLOR_PROFILE_ERROR, 0,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
gimp_color_profile_get_label (profile), babl_error);
|
|
|
|
|
|
|
|
|
|
return space;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-03 02:29:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* gimp_color_profile_get_format:
|
|
|
|
|
* @profile: a #GimpColorProfile
|
|
|
|
|
* @format: a #Babl format
|
2018-07-16 20:06:32 +08:00
|
|
|
|
* @intent: a #GimpColorRenderingIntent
|
2017-09-03 02:29:29 +08:00
|
|
|
|
* @error: return location for #GError
|
|
|
|
|
*
|
|
|
|
|
* This function takes a #GimpColorProfile and a #Babl format and
|
|
|
|
|
* returns a new #Babl format with @profile's RGB primaries and TRC,
|
|
|
|
|
* and @format's pixel layout.
|
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
|
* Returns: the new #Babl format.
|
2017-09-03 02:29:29 +08:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
|
|
|
|
const Babl *
|
2017-09-14 06:12:08 +08:00
|
|
|
|
gimp_color_profile_get_format (GimpColorProfile *profile,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
|
GError **error)
|
2017-09-03 02:29:29 +08:00
|
|
|
|
{
|
2018-07-16 20:06:32 +08:00
|
|
|
|
const Babl *space;
|
2017-09-03 02:29:29 +08:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
|
|
|
|
|
g_return_val_if_fail (format != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2018-07-16 20:06:32 +08:00
|
|
|
|
space = gimp_color_profile_get_space (profile, intent, error);
|
2017-09-03 02:29:29 +08:00
|
|
|
|
|
|
|
|
|
if (! space)
|
2018-07-16 20:06:32 +08:00
|
|
|
|
return NULL;
|
2017-09-03 02:29:29 +08:00
|
|
|
|
|
2019-01-01 23:34:57 +08:00
|
|
|
|
return babl_format_with_space ((const gchar *) format, space);
|
2017-09-03 02:29:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 18:44:44 +08:00
|
|
|
|
/**
|
2017-09-03 00:47:04 +08:00
|
|
|
|
* gimp_color_profile_get_lcms_format:
|
2015-05-08 18:44:44 +08:00
|
|
|
|
* @format: a #Babl format
|
2024-05-11 20:46:10 +08:00
|
|
|
|
* @lcms_format: (out): return location for an lcms format
|
2015-05-08 18:44:44 +08:00
|
|
|
|
*
|
|
|
|
|
* This function takes a #Babl format and returns the lcms format to
|
|
|
|
|
* be used with that @format. It also returns a #Babl format to be
|
|
|
|
|
* used instead of the passed @format, which usually is the same as
|
|
|
|
|
* @format, unless lcms doesn't support @format.
|
|
|
|
|
*
|
2015-09-06 20:12:58 +08:00
|
|
|
|
* Note that this function currently only supports RGB, RGBA, R'G'B',
|
2016-04-08 04:11:45 +08:00
|
|
|
|
* R'G'B'A, Y, YA, Y', Y'A and the cairo-RGB24 and cairo-ARGB32 formats.
|
2015-05-08 18:44:44 +08:00
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
|
* Returns: (nullable): the #Babl format to be used instead of @format, or %NULL
|
2017-02-24 19:50:57 +08:00
|
|
|
|
* if the passed @format is not supported at all.
|
2015-05-08 18:44:44 +08:00
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
|
* Since: 2.10
|
2015-05-08 18:44:44 +08:00
|
|
|
|
**/
|
|
|
|
|
const Babl *
|
2017-09-03 00:47:04 +08:00
|
|
|
|
gimp_color_profile_get_lcms_format (const Babl *format,
|
|
|
|
|
guint32 *lcms_format)
|
2015-05-08 18:44:44 +08:00
|
|
|
|
{
|
|
|
|
|
const Babl *output_format = NULL;
|
|
|
|
|
const Babl *type;
|
|
|
|
|
const Babl *model;
|
2019-05-28 06:33:20 +08:00
|
|
|
|
const Babl *space;
|
2015-05-08 18:44:44 +08:00
|
|
|
|
gboolean has_alpha;
|
2019-05-28 06:33:20 +08:00
|
|
|
|
gboolean rgb = FALSE;
|
|
|
|
|
gboolean gray = FALSE;
|
|
|
|
|
gboolean cmyk = FALSE;
|
|
|
|
|
gboolean linear = FALSE;
|
|
|
|
|
gboolean srgb_trc = FALSE;
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (format != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (lcms_format != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
has_alpha = babl_format_has_alpha (format);
|
|
|
|
|
type = babl_format_get_type (format, 0);
|
|
|
|
|
model = babl_format_get_model (format);
|
2019-05-28 06:33:20 +08:00
|
|
|
|
space = babl_format_get_space (format);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
2015-09-06 20:12:58 +08:00
|
|
|
|
if (format == babl_format ("cairo-RGB24"))
|
2015-09-03 02:31:31 +08:00
|
|
|
|
{
|
2016-05-25 18:24:06 +08:00
|
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
|
*lcms_format = TYPE_BGRA_8;
|
|
|
|
|
#else
|
|
|
|
|
*lcms_format = TYPE_ARGB_8;
|
|
|
|
|
#endif
|
2015-09-03 02:31:31 +08:00
|
|
|
|
|
2016-05-25 18:24:06 +08:00
|
|
|
|
return format;
|
2015-09-03 02:31:31 +08:00
|
|
|
|
}
|
|
|
|
|
else if (format == babl_format ("cairo-ARGB32"))
|
|
|
|
|
{
|
2018-03-17 00:31:55 +08:00
|
|
|
|
rgb = TRUE;
|
2015-09-03 02:31:31 +08:00
|
|
|
|
}
|
2016-06-08 06:00:36 +08:00
|
|
|
|
else if (model == babl_model ("RGB") ||
|
|
|
|
|
model == babl_model ("RGBA") ||
|
|
|
|
|
model == babl_model ("RaGaBaA"))
|
2015-09-06 20:12:58 +08:00
|
|
|
|
{
|
2016-05-27 06:33:56 +08:00
|
|
|
|
rgb = TRUE;
|
2015-09-06 20:12:58 +08:00
|
|
|
|
linear = TRUE;
|
|
|
|
|
}
|
2019-05-28 06:33:20 +08:00
|
|
|
|
else if (model == babl_model ("R~G~B~") ||
|
|
|
|
|
model == babl_model ("R~G~B~A") ||
|
|
|
|
|
model == babl_model ("R~aG~aB~aA"))
|
|
|
|
|
{
|
|
|
|
|
rgb = TRUE;
|
|
|
|
|
srgb_trc = TRUE;
|
|
|
|
|
}
|
2016-06-08 06:00:36 +08:00
|
|
|
|
else if (model == babl_model ("R'G'B'") ||
|
|
|
|
|
model == babl_model ("R'G'B'A") ||
|
|
|
|
|
model == babl_model ("R'aG'aB'aA"))
|
2015-09-06 20:12:58 +08:00
|
|
|
|
{
|
2016-05-27 06:33:56 +08:00
|
|
|
|
rgb = TRUE;
|
2015-12-15 06:16:38 +08:00
|
|
|
|
}
|
2016-06-08 06:00:36 +08:00
|
|
|
|
else if (model == babl_model ("Y") ||
|
|
|
|
|
model == babl_model ("YA") ||
|
|
|
|
|
model == babl_model ("YaA"))
|
2015-12-15 06:16:38 +08:00
|
|
|
|
{
|
|
|
|
|
gray = TRUE;
|
|
|
|
|
linear = TRUE;
|
|
|
|
|
}
|
2019-05-28 06:33:20 +08:00
|
|
|
|
else if (model == babl_model ("Y~") ||
|
|
|
|
|
model == babl_model ("Y~A") ||
|
|
|
|
|
model == babl_model ("Y~aA"))
|
|
|
|
|
{
|
|
|
|
|
gray = TRUE;
|
|
|
|
|
srgb_trc = TRUE;
|
|
|
|
|
}
|
2016-06-08 06:00:36 +08:00
|
|
|
|
else if (model == babl_model ("Y'") ||
|
|
|
|
|
model == babl_model ("Y'A") ||
|
|
|
|
|
model == babl_model ("Y'aA"))
|
2015-12-15 06:16:38 +08:00
|
|
|
|
{
|
2016-05-27 06:33:56 +08:00
|
|
|
|
gray = TRUE;
|
|
|
|
|
}
|
2016-06-08 06:00:36 +08:00
|
|
|
|
else if (model == babl_model ("CMYK"))
|
|
|
|
|
#if 0
|
|
|
|
|
/* FIXME missing from babl */
|
|
|
|
|
|| model == babl_model ("CMYKA"))
|
|
|
|
|
#endif
|
2016-05-27 06:33:56 +08:00
|
|
|
|
{
|
|
|
|
|
cmyk = TRUE;
|
2015-09-06 20:12:58 +08:00
|
|
|
|
}
|
2018-03-19 01:46:25 +08:00
|
|
|
|
else if (model == babl_model ("CIE Lab") ||
|
|
|
|
|
model == babl_model ("CIE Lab alpha") ||
|
|
|
|
|
model == babl_model ("CIE LCH(ab)") ||
|
|
|
|
|
model == babl_model ("CIE LCH(ab) alpha"))
|
2017-02-24 19:50:57 +08:00
|
|
|
|
{
|
|
|
|
|
if (has_alpha)
|
|
|
|
|
{
|
|
|
|
|
*lcms_format = TYPE_RGBA_FLT;
|
|
|
|
|
|
2019-05-28 06:33:20 +08:00
|
|
|
|
return babl_format_with_space ("RGBA float", space);
|
2017-02-24 19:50:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*lcms_format = TYPE_RGB_FLT;
|
|
|
|
|
|
2019-05-28 06:33:20 +08:00
|
|
|
|
return babl_format_with_space ("RGB float", space);
|
2017-02-24 19:50:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-27 06:48:23 +08:00
|
|
|
|
else if (babl_format_is_palette (format))
|
|
|
|
|
{
|
|
|
|
|
if (has_alpha)
|
|
|
|
|
{
|
|
|
|
|
*lcms_format = TYPE_RGBA_8;
|
|
|
|
|
|
2019-05-28 06:33:20 +08:00
|
|
|
|
return babl_format_with_space ("R'G'B'A u8", space);
|
2016-04-27 06:48:23 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*lcms_format = TYPE_RGB_8;
|
|
|
|
|
|
2019-05-28 06:33:20 +08:00
|
|
|
|
return babl_format_with_space ("R'G'B' u8", space);
|
2016-04-27 06:48:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-05-08 18:44:44 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-05-28 23:37:08 +08:00
|
|
|
|
g_printerr ("format not supported: %s\n"
|
2015-09-03 02:31:31 +08:00
|
|
|
|
"has_alpha = %s\n"
|
|
|
|
|
"type = %s\n"
|
|
|
|
|
"model = %s\n",
|
|
|
|
|
babl_get_name (format),
|
|
|
|
|
has_alpha ? "TRUE" : "FALSE",
|
|
|
|
|
babl_get_name (type),
|
|
|
|
|
babl_get_name (model));
|
2015-05-08 18:44:44 +08:00
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*lcms_format = 0;
|
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
#define FIND_FORMAT_FOR_TYPE(babl_t, lcms_t) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
if (has_alpha) \
|
|
|
|
|
{ \
|
|
|
|
|
if (rgb) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_RGBA_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
if (linear) \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("RGBA " babl_t, \
|
|
|
|
|
space); \
|
|
|
|
|
else if (srgb_trc) \
|
|
|
|
|
output_format = babl_format_with_space ("R~G~B~A " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
else \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("R'G'B'A " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
} \
|
|
|
|
|
else if (gray) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_GRAYA_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
if (linear) \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("YA " babl_t, \
|
|
|
|
|
space); \
|
|
|
|
|
else if (srgb_trc) \
|
|
|
|
|
output_format = babl_format_with_space ("Y~A " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
else \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("Y'A " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
} \
|
|
|
|
|
else if (cmyk) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_CMYKA_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
output_format = format; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
if (rgb) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_RGB_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
if (linear) \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("RGB " babl_t, \
|
|
|
|
|
space); \
|
|
|
|
|
else if (srgb_trc) \
|
|
|
|
|
output_format = babl_format_with_space ("R~G~B~ " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
else \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("R'G'B' " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
} \
|
|
|
|
|
else if (gray) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_GRAY_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
if (linear) \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("Y " babl_t, \
|
|
|
|
|
space); \
|
|
|
|
|
else if (srgb_trc) \
|
|
|
|
|
output_format = babl_format_with_space ("Y~ " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
else \
|
2019-05-28 06:33:20 +08:00
|
|
|
|
output_format = babl_format_with_space ("Y' " babl_t, \
|
|
|
|
|
space); \
|
2018-03-17 00:31:55 +08:00
|
|
|
|
} \
|
|
|
|
|
else if (cmyk) \
|
|
|
|
|
{ \
|
|
|
|
|
*lcms_format = TYPE_CMYK_##lcms_t; \
|
|
|
|
|
\
|
|
|
|
|
output_format = format; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
while (FALSE)
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
if (type == babl_type ("u8"))
|
|
|
|
|
FIND_FORMAT_FOR_TYPE ("u8", 8);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
else if (type == babl_type ("u16"))
|
2018-03-17 00:31:55 +08:00
|
|
|
|
FIND_FORMAT_FOR_TYPE ("u16", 16);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
else if (type == babl_type ("half")) /* 16-bit floating point (half) */
|
2018-03-17 00:31:55 +08:00
|
|
|
|
FIND_FORMAT_FOR_TYPE ("half", HALF_FLT);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
else if (type == babl_type ("float"))
|
2018-03-17 00:31:55 +08:00
|
|
|
|
FIND_FORMAT_FOR_TYPE ("float", FLT);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
else if (type == babl_type ("double"))
|
2018-03-17 00:31:55 +08:00
|
|
|
|
FIND_FORMAT_FOR_TYPE ("double", DBL);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
|
|
|
|
if (*lcms_format == 0)
|
|
|
|
|
{
|
2016-06-08 06:00:36 +08:00
|
|
|
|
g_printerr ("%s: format %s not supported, "
|
2015-05-08 18:44:44 +08:00
|
|
|
|
"falling back to float\n",
|
2015-06-13 02:43:17 +08:00
|
|
|
|
G_STRFUNC, babl_get_name (format));
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
rgb = ! gray;
|
2015-05-08 18:44:44 +08:00
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
FIND_FORMAT_FOR_TYPE ("float", FLT);
|
2015-12-15 06:16:38 +08:00
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
g_return_val_if_fail (output_format != NULL, NULL);
|
2015-05-08 18:44:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-17 00:31:55 +08:00
|
|
|
|
#undef FIND_FORMAT_FOR_TYPE
|
|
|
|
|
|
2015-05-08 18:44:44 +08:00
|
|
|
|
return output_format;
|
|
|
|
|
}
|