[gimp] app: add ICC data/length parameters to gimp_layer_new_from_gegl_buffer()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add ICC data/length parameters to gimp_layer_new_from_gegl_buffer()
- Date: Fri, 19 Jun 2015 22:40:38 +0000 (UTC)
commit 09cd5f6720d08924ac6e07d284231a42bb002f2f
Author: Michael Natterer <mitch gimp org>
Date: Sat Jun 20 00:33:22 2015 +0200
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.
app/actions/layers-commands.c | 3 +-
app/core/gimp-utils.c | 9 ++++---
app/core/gimpdrawable-transform.c | 3 +-
app/core/gimplayer-new.c | 45 +++++++++++++++++++++++++++++++++++-
app/core/gimplayer-new.h | 4 ++-
app/core/gimpselection.c | 3 +-
app/pdb/layer-cmds.c | 8 +++++-
tools/pdbgen/pdb/layer.pdb | 8 +++++-
8 files changed, 71 insertions(+), 12 deletions(-)
---
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index a8af7e2..9852024 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -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);
diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c
index 8cc5105..1be3109 100644
--- a/app/core/gimp-utils.c
+++ b/app/core/gimp-utils.c
@@ -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);
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index e3fb1e5..e2c9c60 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -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);
diff --git a/app/core/gimplayer-new.c b/app/core/gimplayer-new.c
index 7035239..b99cb77 100644
--- a/app/core/gimplayer-new.c
+++ b/app/core/gimplayer-new.c
@@ -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 */
+}
diff --git a/app/core/gimplayer-new.h b/app/core/gimplayer-new.h
index df99831..d369c88 100644
--- a/app/core/gimplayer-new.h
+++ b/app/core/gimplayer-new.h
@@ -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,
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 49c2c35..c43c041 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -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);
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 55192a2..d3819be 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -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,
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index 264bb37..c2b46df 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -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"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]