Example #1
0
/**
 * gimp_color_profile_new_srgb:
 *
 * 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 #GimpColorProfile.
 *
 * Since: 2.10
 **/
GimpColorProfile *
gimp_color_profile_new_srgb (void)
{
  static GimpColorProfile *profile = NULL;

  const guint8 *data;
  gsize         length;

  if (G_UNLIKELY (profile == NULL))
    {
      cmsHPROFILE lcms_profile = gimp_color_profile_new_srgb_internal ();

      profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);

      cmsCloseProfile (lcms_profile);

#if 0
      /* for testing the code to get the colorants and make a new profile */
      {
        GimpMatrix3 matrix;

        if (gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix))
          {
            GimpColorProfile *test;

            g_printerr ("Profile Red colorant XYZ: %1.8f, %1.8f, %1.8f \n",
                        matrix.coeff[0][0],
                        matrix.coeff[0][1],
                        matrix.coeff[0][2]);
            g_printerr ("Profile Green colorant XYZ: %1.8f, %1.8f, %1.8f \n",
                        matrix.coeff[1][0],
                        matrix.coeff[1][1],
                        matrix.coeff[1][2]);
            g_printerr ("Profile Blue colorant XYZ: %1.8f, %1.8f, %1.8f \n",
                        matrix.coeff[2][0],
                        matrix.coeff[2][1],
                        matrix.coeff[2][2]);

            test = gimp_color_profile_new_foobar (profile);
            g_object_unref (test);
          }
      }
#endif
    }

  data = gimp_color_profile_get_icc_profile (profile, &length);

  return gimp_color_profile_new_from_icc_profile (data, length, NULL);
}
Example #2
0
/**
 * gimp_color_profile_new_srgb:
 *
 * 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: 2.10
 **/
GimpColorProfile
gimp_color_profile_new_srgb (void)
{
  static guint8 *profile_data   = NULL;
  static gsize   profile_length = 0;

  if (G_UNLIKELY (profile_data == NULL))
    {
      GimpColorProfile profile;

      profile = gimp_color_profile_new_srgb_internal ();

      profile_data = gimp_color_profile_save_to_data (profile, &profile_length,
                                                      NULL);

      gimp_color_profile_close (profile);
    }

  return gimp_color_profile_open_from_data (profile_data, profile_length, NULL);
}