/** * 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. * * 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. * * Return value: the sRGB cmsHPROFILE. * * Since: GIMP 2.10 **/ GimpColorProfile gimp_lcms_create_srgb_profile (void) { static guint8 *profile_data = NULL; static gsize profile_length = 0; if (G_UNLIKELY (profile_data == NULL)) { GimpColorProfile profile; profile = gimp_lcms_create_srgb_profile_internal (); profile_data = gimp_lcms_profile_save_to_data (profile, &profile_length, NULL); cmsCloseProfile (profile); } return gimp_lcms_profile_open_from_data (profile_data, profile_length, NULL); }
static gboolean lcms_image_set_profile (gint32 image, cmsHPROFILE profile, GFile *file) { g_return_val_if_fail (image != -1, FALSE); if (file) { cmsHPROFILE file_profile; GimpParasite *parasite; guint8 *profile_data; gsize profile_length; GError *error = NULL; /* check that this file is actually an ICC profile */ file_profile = gimp_lcms_profile_open_from_file (file, &error); if (! file_profile) { g_message ("%s", error->message); g_clear_error (&error); return FALSE; } profile_data = gimp_lcms_profile_save_to_data (file_profile, &profile_length, &error); cmsCloseProfile (file_profile); if (! profile_data) { g_message ("%s", error->message); g_clear_error (&error); return FALSE; } gimp_image_undo_group_start (image); parasite = gimp_parasite_new ("icc-profile", GIMP_PARASITE_PERSISTENT | GIMP_PARASITE_UNDOABLE, profile_length, profile_data); g_free (profile_data); gimp_image_attach_parasite (image, parasite); gimp_parasite_free (parasite); } else { gimp_image_undo_group_start (image); gimp_image_detach_parasite (image, "icc-profile"); } gimp_image_detach_parasite (image, "icc-profile-name"); gimp_image_undo_group_end (image); return TRUE; }