[gimp/goat-invasion: 29/325] app: add gimp_layer_new_from_buffer()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 29/325] app: add gimp_layer_new_from_buffer()
- Date: Fri, 30 Mar 2012 09:36:42 +0000 (UTC)
commit 083cc236d52a42a5437b9fc1d3310c0e1361a637
Author: Michael Natterer <mitch gimp org>
Date: Wed Mar 14 21:36:42 2012 +0100
app: add gimp_layer_new_from_buffer()
app/core/gimplayer.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
app/core/gimplayer.h | 6 ++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 1853acf..1f472ee 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1166,6 +1166,51 @@ gimp_layer_new (GimpImage *image,
}
/**
+ * gimp_layer_new_from_buffer:
+ * @buffer: The buffer to make the new layer from.
+ * @dest_image: The image the new layer will be added to.
+ * @type: The #GimpImageType of the new layer.
+ * @name: The new layer's name.
+ * @opacity: The new layer's opacity.
+ * @mode: The new layer's mode.
+ *
+ * Copies %buffer 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_buffer (GeglBuffer *buffer,
+ GimpImage *dest_image,
+ GimpImageType type,
+ const gchar *name,
+ gdouble opacity,
+ GimpLayerModeEffects mode)
+{
+ GimpLayer *layer;
+ GeglBuffer *dest;
+
+ g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
+ g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
+
+ layer = gimp_layer_new (dest_image,
+ gegl_buffer_get_width (buffer),
+ gegl_buffer_get_height (buffer),
+ type, name,
+ opacity, mode);
+
+ dest = gimp_tile_manager_get_gegl_buffer (gimp_drawable_get_tiles (GIMP_DRAWABLE (layer)),
+ TRUE);
+
+ gegl_buffer_copy (buffer, NULL, dest, NULL);
+
+ g_object_unref (dest);
+
+ return layer;
+}
+
+/**
* gimp_layer_new_from_tiles:
* @tiles: The buffer to make the new layer from.
* @dest_image: The image the new layer will be added to.
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index 94307fc..a491719 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -77,6 +77,12 @@ GimpLayer * gimp_layer_new (GimpImage *image,
gdouble opacity,
GimpLayerModeEffects mode);
+GimpLayer * gimp_layer_new_from_buffer (GeglBuffer *buffer,
+ GimpImage *dest_image,
+ GimpImageType type,
+ const gchar *name,
+ gdouble opacity,
+ GimpLayerModeEffects mode);
GimpLayer * gimp_layer_new_from_tiles (TileManager *tiles,
GimpImage *dest_image,
GimpImageType type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]