mirror of https://github.com/GNOME/gimp.git
app: add ICC data/length parameters to gimp_layer_new_from_gegl_buffer()
and pass them where we know the buffer could be from another image. Pass "NULL, 0" if we know it's the same image. Add gimp_layer_new_convert_profile() which takes the newly created layer and the ICC data/length; call it from both gimp_layer_new_from_gegl_buffer() and gimp_layer_new_from_pixbuf(). gimp_layer_new_convert_profile() is empty, this is just infrastructure.
This commit is contained in:
parent
6446c007cf
commit
09cd5f6720
|
@ -363,7 +363,8 @@ layers_new_from_visible_cmd_callback (GtkAction *action,
|
|||
TRUE),
|
||||
_("Visible"),
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE);
|
||||
GIMP_NORMAL_MODE,
|
||||
NULL, 0 /* same image */);
|
||||
|
||||
gimp_image_add_layer (image, layer,
|
||||
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
||||
|
|
|
@ -777,10 +777,11 @@ gimp_create_image_from_buffer (Gimp *gimp,
|
|||
gimp_babl_format_get_precision (format),
|
||||
FALSE);
|
||||
|
||||
layer = gimp_layer_new_from_buffer (buffer, image, format,
|
||||
image_name,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE);
|
||||
layer = gimp_layer_new_from_gegl_buffer (buffer, image, format,
|
||||
image_name,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE,
|
||||
NULL, 0 /* same image */);
|
||||
gimp_image_add_layer (image, layer, NULL, -1, FALSE);
|
||||
|
||||
gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0, NULL, 0);
|
||||
|
|
|
@ -962,7 +962,8 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
|
|||
gimp_layer_new_from_gegl_buffer (buffer, image,
|
||||
gimp_drawable_get_format_with_alpha (drawable),
|
||||
_("Transformation"),
|
||||
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
||||
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
|
||||
NULL, 0 /* same image */);
|
||||
|
||||
gimp_item_set_offset (GIMP_ITEM (layer), offset_x, offset_y);
|
||||
|
||||
|
|
|
@ -31,6 +31,15 @@
|
|||
#include "gimplayer-new.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_layer_new_convert_profile (GimpLayer *layer,
|
||||
const guint8 *icc_data,
|
||||
gsize icc_length);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpLayer *
|
||||
gimp_layer_new (GimpImage *image,
|
||||
gint width,
|
||||
|
@ -83,13 +92,19 @@ gimp_layer_new_from_buffer (GimpBuffer *buffer,
|
|||
gdouble opacity,
|
||||
GimpLayerModeEffects mode)
|
||||
{
|
||||
const guint8 *icc_data;
|
||||
gsize icc_len;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
icc_data = gimp_buffer_get_icc_profile (buffer, &icc_len);
|
||||
|
||||
return gimp_layer_new_from_gegl_buffer (gimp_buffer_get_buffer (buffer),
|
||||
dest_image, format,
|
||||
name, opacity, mode);
|
||||
name, opacity, mode,
|
||||
icc_data, icc_len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +128,9 @@ gimp_layer_new_from_gegl_buffer (GeglBuffer *buffer,
|
|||
const Babl *format,
|
||||
const gchar *name,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects mode)
|
||||
GimpLayerModeEffects mode,
|
||||
const guint8 *buffer_icc_data,
|
||||
gsize buffer_icc_length)
|
||||
{
|
||||
GimpLayer *layer;
|
||||
GeglBuffer *dest;
|
||||
|
@ -121,6 +138,7 @@ gimp_layer_new_from_gegl_buffer (GeglBuffer *buffer,
|
|||
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
g_return_val_if_fail (buffer_icc_data != NULL || buffer_icc_length == 0, NULL);
|
||||
|
||||
/* do *not* use the buffer's format because this function gets
|
||||
* buffers of any format passed, and converts them
|
||||
|
@ -134,6 +152,9 @@ gimp_layer_new_from_gegl_buffer (GeglBuffer *buffer,
|
|||
dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
|
||||
gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, dest, NULL);
|
||||
|
||||
if (buffer_icc_data)
|
||||
gimp_layer_new_convert_profile (layer, buffer_icc_data, buffer_icc_length);
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
@ -164,6 +185,8 @@ gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
|||
GimpLayer *layer;
|
||||
gint width;
|
||||
gint height;
|
||||
guint8 *icc_data;
|
||||
gsize icc_len;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
||||
|
@ -182,5 +205,23 @@ gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
|||
gdk_pixbuf_get_pixels (pixbuf),
|
||||
gdk_pixbuf_get_rowstride (pixbuf));
|
||||
|
||||
icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);
|
||||
if (icc_data)
|
||||
{
|
||||
gimp_layer_new_convert_profile (layer, icc_data, icc_len);
|
||||
g_free (icc_data);
|
||||
}
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_layer_new_convert_profile (GimpLayer *layer,
|
||||
const guint8 *icc_data,
|
||||
gsize icc_length)
|
||||
{
|
||||
/* FIXME implement */
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ GimpLayer * gimp_layer_new_from_gegl_buffer (GeglBuffer *buffer,
|
|||
const Babl *format,
|
||||
const gchar *name,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects mode);
|
||||
GimpLayerModeEffects mode,
|
||||
const guint8 *buffer_icc_data,
|
||||
gsize buffer_icc_length);
|
||||
GimpLayer * gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
||||
GimpImage *dest_image,
|
||||
const Babl *format,
|
||||
|
|
|
@ -845,7 +845,8 @@ gimp_selection_float (GimpSelection *selection,
|
|||
gimp_drawable_get_format_with_alpha (drawable),
|
||||
_("Floated Layer"),
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE);
|
||||
GIMP_NORMAL_MODE,
|
||||
NULL, 0 /* same image */);
|
||||
|
||||
/* Set the offsets */
|
||||
gimp_item_set_offset (GIMP_ITEM (layer), x1 + off_x, y1 + off_y);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpgrouplayer.h"
|
||||
#include "core/gimpimage-profile.h"
|
||||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpitem-linked.h"
|
||||
|
@ -165,16 +166,21 @@ layer_new_from_visible_invoker (GimpProcedure *procedure,
|
|||
if (success)
|
||||
{
|
||||
GimpPickable *pickable = GIMP_PICKABLE (image);
|
||||
const guint8 *icc_data;
|
||||
gsize icc_len;
|
||||
|
||||
gimp_pickable_flush (pickable);
|
||||
|
||||
icc_data = gimp_image_get_icc_profile (image, &icc_len);
|
||||
|
||||
layer = gimp_layer_new_from_gegl_buffer (gimp_pickable_get_buffer (pickable),
|
||||
dest_image,
|
||||
gimp_image_get_layer_format (dest_image,
|
||||
TRUE),
|
||||
name,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE);
|
||||
GIMP_NORMAL_MODE,
|
||||
icc_data, icc_len);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
|
|
|
@ -143,16 +143,21 @@ HELP
|
|||
code => <<'CODE'
|
||||
{
|
||||
GimpPickable *pickable = GIMP_PICKABLE (image);
|
||||
const guint8 *icc_data;
|
||||
gsize icc_len;
|
||||
|
||||
gimp_pickable_flush (pickable);
|
||||
|
||||
icc_data = gimp_image_get_icc_profile (image, &icc_len);
|
||||
|
||||
layer = gimp_layer_new_from_gegl_buffer (gimp_pickable_get_buffer (pickable),
|
||||
dest_image,
|
||||
gimp_image_get_layer_format (dest_image,
|
||||
TRUE),
|
||||
name,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
GIMP_NORMAL_MODE);
|
||||
GIMP_NORMAL_MODE,
|
||||
icc_data, icc_len);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
@ -1197,6 +1202,7 @@ CODE
|
|||
|
||||
@headers = qw("libgimpbase/gimpbase.h"
|
||||
"core/gimp.h"
|
||||
"core/gimpimage-profile.h"
|
||||
"core/gimpimage-undo.h"
|
||||
"core/gimpitem-linked.h"
|
||||
"core/gimpgrouplayer.h"
|
||||
|
|
Loading…
Reference in New Issue