Example #1
0
static const guint8 *
gimp_buffer_color_managed_get_icc_profile (GimpColorManaged *managed,
                             gsize            *len)
{
  GimpBuffer *buffer = GIMP_BUFFER (managed);

  if (buffer->color_profile)
    return gimp_color_profile_get_icc_profile (buffer->color_profile, len);

  return 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 #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 #3
0
static GimpValueArray *
image_get_color_profile_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
                                 GimpProgress          *progress,
                                 const GimpValueArray  *args,
                                 GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 num_bytes = 0;
  guint8 *profile_data = NULL;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      GimpColorProfile *profile;

      profile = gimp_image_get_color_profile (image);

      if (profile)
        {
          const guint8 *data;
          gsize         length;

          data = gimp_color_profile_get_icc_profile (profile, &length);

          profile_data = g_memdup (data, length);
          num_bytes = length;

          g_object_unref (profile);
        }
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
      gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
    }

  return return_vals;
}
gboolean
gimp_image_set_color_profile (GimpImage         *image,
                              GimpColorProfile  *profile,
                              GError           **error)
{
  const guint8 *data   = NULL;
  gsize         length = 0;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
  g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
                        FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  if (profile)
    data = gimp_color_profile_get_icc_profile (profile, &length);

  return gimp_image_set_icc_profile (image, data, length, error);
}
Example #5
0
/**
 * 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.
 *
 * Return value: a gray profile with the D50 ICC profile illuminant
 * 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;
  gsize         length;

  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);
}