app: add gimp_channel_new_from_buffer() and gimp_layer_mask_new_from_buffer()

This commit is contained in:
Miroslav Talasek 2013-05-07 23:06:43 +02:00 committed by Michael Natterer
parent 02505451b1
commit 0d7b10cb74
4 changed files with 63 additions and 10 deletions

View File

@ -1554,6 +1554,29 @@ gimp_channel_new (GimpImage *image,
return channel;
}
GimpChannel *
gimp_channel_new_from_buffer (GeglBuffer *buffer,
GimpImage *image,
const gchar *name,
const GimpRGB *color)
{
GimpChannel *channel;
GeglBuffer *dest;
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
channel = gimp_channel_new (image,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer),
name, color);
dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (channel));
gegl_buffer_copy (buffer, NULL, dest, NULL);
return channel;
}
GimpChannel *
gimp_channel_new_from_alpha (GimpImage *image,
GimpDrawable *drawable,

View File

@ -128,7 +128,10 @@ GimpChannel * gimp_channel_new (GimpImage *image,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_buffer (GeglBuffer *buffer,
GimpImage *image,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *image,
GimpDrawable *drawable,
const gchar *name,

View File

@ -211,6 +211,29 @@ gimp_layer_mask_new (GimpImage *image,
return layer_mask;
}
GimpLayerMask *
gimp_layer_mask_new_from_buffer (GeglBuffer *buffer,
GimpImage *image,
const gchar *name,
const GimpRGB *color)
{
GimpLayerMask *layer_mask;
GeglBuffer *dest;
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
layer_mask = gimp_layer_mask_new (image,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer),
name, color);
dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer_mask));
gegl_buffer_copy (buffer, NULL, dest, NULL);
return layer_mask;
}
void
gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer)

View File

@ -47,17 +47,21 @@ struct _GimpLayerMaskClass
/* function declarations */
GType gimp_layer_mask_get_type (void) G_GNUC_CONST;
GType gimp_layer_mask_get_type (void) G_GNUC_CONST;
GimpLayerMask * gimp_layer_mask_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpLayerMask * gimp_layer_mask_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpLayerMask * gimp_layer_mask_new_from_buffer (GeglBuffer *buffer,
GimpImage *image,
const gchar *name,
const GimpRGB *color);
void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer);
GimpLayer * gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask);
void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer);
GimpLayer * gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask);
#endif /* __GIMP_LAYER_MASK_H__ */