Пример #1
0
GimpBuffer *
gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
                             const gchar *name,
                             gint         offset_x,
                             gint         offset_y)
{
  GimpBuffer *gimp_buffer;
  GeglBuffer *buffer;
  guint8     *icc_data;
  gsize       icc_len;

  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
  g_return_val_if_fail (name != NULL, NULL);

  buffer = gimp_pixbuf_create_buffer (pixbuf);

  gimp_buffer = gimp_buffer_new (buffer, name,
                                 offset_x, offset_y, FALSE);

  icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);

  if (icc_data)
    {
      gimp_buffer_set_icc_profile (gimp_buffer, icc_data, icc_len);
      g_free (icc_data);
    }

  g_object_unref (buffer);

  return gimp_buffer;
}
Пример #2
0
/**
 * gimp_layer_new_from_pixbuf:
 * @pixbuf:     The pixbuf to make the new layer from.
 * @dest_image: The image the new layer will be added to.
 * @format:     The #Babl format of the new layer.
 * @name:       The new layer's name.
 * @opacity:    The new layer's opacity.
 * @mode:       The new layer's mode.
 *
 * Copies %pixbuf to a layer taking into consideration the
 * possibility of transforming the contents to meet the requirements
 * of the target image type
 *
 * Return value: The new layer.
 **/
GimpLayer *
gimp_layer_new_from_pixbuf (GdkPixbuf            *pixbuf,
                            GimpImage            *dest_image,
                            const Babl           *format,
                            const gchar          *name,
                            gdouble               opacity,
                            GimpLayerModeEffects  mode)
{
  GimpLayer        *layer;
  GeglBuffer       *buffer;
  guint8           *icc_data;
  gsize             icc_len;
  GimpColorProfile *profile = NULL;

  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
  g_return_val_if_fail (format != NULL, NULL);

  layer = gimp_layer_new (dest_image,
                          gdk_pixbuf_get_width  (pixbuf),
                          gdk_pixbuf_get_height (pixbuf),
                          format, name, opacity, mode);

  buffer = gimp_pixbuf_create_buffer (pixbuf);

  icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);
  if (icc_data)
    {
      profile = gimp_color_profile_new_from_icc_profile (icc_data, icc_len,
                                                         NULL);
      g_free (icc_data);
    }

  if (! profile && gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB)
    {
      profile = gimp_color_profile_new_srgb ();
    }

  gimp_layer_new_convert_buffer (layer, buffer, profile, NULL);

  if (profile)
    g_object_unref (profile);

  g_object_unref (buffer);

  return layer;
}
Пример #3
0
GimpBuffer *
gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
                             const gchar *name,
                             gint         offset_x,
                             gint         offset_y)
{
  GimpBuffer       *gimp_buffer;
  GeglBuffer       *buffer;
  guint8           *icc_data;
  gsize             icc_len;
  GimpColorProfile *profile = NULL;

  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
  g_return_val_if_fail (name != NULL, NULL);

  buffer = gimp_pixbuf_create_buffer (pixbuf);

  gimp_buffer = gimp_buffer_new (buffer, name,
                                 offset_x, offset_y, FALSE);

  icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);
  if (icc_data)
    {
      profile = gimp_color_profile_new_from_icc_profile (icc_data, icc_len,
                                                         NULL);
      g_free (icc_data);
    }

  if (! profile && gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB)
    {
      profile = gimp_color_profile_new_rgb_srgb ();
    }

  if (profile)
    {
      gimp_buffer_set_color_profile (gimp_buffer, profile);
      g_object_unref (profile);
    }

  g_object_unref (buffer);

  return gimp_buffer;
}