2015-06-05 18:51:46 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpimagecolorprofile.c
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Lesser 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/>.
|
2015-06-05 18:51:46 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_get_color_profile:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2015-06-05 18:51:46 +08:00
|
|
|
*
|
|
|
|
* Returns the image's color profile
|
|
|
|
*
|
2015-06-07 07:38:50 +08:00
|
|
|
* This procedure returns the image's color profile, or NULL if the
|
|
|
|
* image has no color profile assigned.
|
2015-06-05 18:51:46 +08:00
|
|
|
*
|
2019-08-01 07:52:07 +08:00
|
|
|
* Returns: (transfer full): The image's color profile. The returned
|
|
|
|
* value must be freed with g_object_unref().
|
2015-06-05 18:51:46 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_color_profile (GimpImage *image)
|
2015-06-05 18:51:46 +08:00
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
gint length;
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
data = _gimp_image_get_color_profile (image, &length);
|
2015-06-05 18:51:46 +08:00
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *profile;
|
2015-06-05 18:51:46 +08:00
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
2015-06-05 18:51:46 +08:00
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_set_color_profile:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
|
|
|
* @profile: A #GimpColorProfile, or %NULL.
|
2015-06-05 18:51:46 +08:00
|
|
|
*
|
|
|
|
* Sets the image's color profile
|
|
|
|
*
|
|
|
|
* This procedure sets the image's color profile.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_set_color_profile (GimpImage *image,
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *profile)
|
2015-06-05 18:51:46 +08:00
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
const guint8 *data = NULL;
|
|
|
|
gint length = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
|
2015-09-25 03:32:33 +08:00
|
|
|
FALSE);
|
2015-06-05 18:51:46 +08:00
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
gsize l;
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &l);
|
2015-06-05 18:51:46 +08:00
|
|
|
length = l;
|
|
|
|
}
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
return _gimp_image_set_color_profile (image, length, data);
|
2015-06-05 18:51:46 +08:00
|
|
|
}
|
2015-06-07 07:38:50 +08:00
|
|
|
|
2022-06-01 04:59:31 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_simulation_profile:
|
|
|
|
* @image: The image.
|
|
|
|
*
|
|
|
|
* Returns the image's simulation color profile
|
|
|
|
*
|
|
|
|
* This procedure returns the image's simulation color profile, or NULL if
|
|
|
|
* the image has no simulation color profile assigned.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): The image's simulation color profile. The
|
|
|
|
* returned value must be freed with g_object_unref().
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GimpColorProfile *
|
|
|
|
gimp_image_get_simulation_profile (GimpImage *image)
|
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
gint length;
|
|
|
|
|
|
|
|
data = _gimp_image_get_simulation_profile (image, &length);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_set_simulation_profile:
|
|
|
|
* @image: The image.
|
|
|
|
* @profile: A #GimpColorProfile, or %NULL.
|
|
|
|
*
|
|
|
|
* Sets the image's simulation color profile
|
|
|
|
*
|
|
|
|
* This procedure sets the image's simulation color profile.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_image_set_simulation_profile (GimpImage *image,
|
|
|
|
GimpColorProfile *profile)
|
|
|
|
{
|
|
|
|
const guint8 *data = NULL;
|
|
|
|
gint length = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
gsize l;
|
|
|
|
|
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &l);
|
|
|
|
length = l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _gimp_image_set_simulation_profile (image, length, data);
|
|
|
|
}
|
|
|
|
|
2015-06-07 07:38:50 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_effective_color_profile:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2015-06-07 07:38:50 +08:00
|
|
|
*
|
|
|
|
* Returns the color profile that is used for the image.
|
|
|
|
*
|
|
|
|
* This procedure returns the color profile that is actually used for
|
|
|
|
* this image, which is the profile returned by
|
|
|
|
* gimp_image_get_color_profile() if the image has a profile assigned,
|
|
|
|
* or the default RGB profile from preferences if no profile is
|
|
|
|
* assigned to the image. If there is no default RGB profile configured
|
|
|
|
* in preferences either, a generated default RGB profile is returned.
|
|
|
|
*
|
2019-08-01 07:52:07 +08:00
|
|
|
* Returns: (transfer full): The color profile. The returned value must
|
|
|
|
* be freed with g_object_unref().
|
2015-06-07 07:38:50 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_effective_color_profile (GimpImage *image)
|
2015-06-07 07:38:50 +08:00
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
gint length;
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
data = _gimp_image_get_effective_color_profile (image, &length);
|
2015-06-07 07:38:50 +08:00
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *profile;
|
2015-06-07 07:38:50 +08:00
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL);
|
2015-06-07 07:38:50 +08:00
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-06-10 07:38:20 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_convert_color_profile:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
|
|
|
* @profile: The color profile to convert to.
|
|
|
|
* @intent: Rendering intent.
|
|
|
|
* @bpc: Black point compensation.
|
2015-06-10 07:38:20 +08:00
|
|
|
*
|
|
|
|
* Convert the image's layers to a color profile
|
|
|
|
*
|
|
|
|
* This procedure converts from the image's color profile (or the
|
|
|
|
* default RGB profile if none is set) to the given color profile. Only
|
|
|
|
* RGB color profiles are accepted.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_convert_color_profile (GimpImage *image,
|
2015-07-11 04:43:53 +08:00
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc)
|
2015-06-10 07:38:20 +08:00
|
|
|
{
|
2015-07-11 04:43:53 +08:00
|
|
|
const guint8 *data = NULL;
|
|
|
|
gint length = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
|
2015-09-25 03:32:33 +08:00
|
|
|
FALSE);
|
2015-06-10 07:38:20 +08:00
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
gsize l;
|
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
data = gimp_color_profile_get_icc_profile (profile, &l);
|
2015-06-10 07:38:20 +08:00
|
|
|
length = l;
|
|
|
|
}
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
return _gimp_image_convert_color_profile (image, length, data,
|
2015-07-11 04:43:53 +08:00
|
|
|
intent, bpc);
|
2015-06-10 07:38:20 +08:00
|
|
|
}
|