[gimp] app: support clipboard images in the clipboard brush and pattern
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: support clipboard images in the clipboard brush and pattern
- Date: Wed, 19 Apr 2017 19:52:48 +0000 (UTC)
commit 6eeb5c2ee2b6ea7041c00aaa9cb1a643dd719edb
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 19 16:52:10 2017 -0300
app: support clipboard images in the clipboard brush and pattern
app/core/gimpbrushclipboard.c | 26 +++++++++++++++++++-------
app/core/gimppatternclipboard.c | 29 +++++++++++++++++++----------
2 files changed, 38 insertions(+), 17 deletions(-)
---
diff --git a/app/core/gimpbrushclipboard.c b/app/core/gimpbrushclipboard.c
index 46fe5c4..3f9df75 100644
--- a/app/core/gimpbrushclipboard.c
+++ b/app/core/gimpbrushclipboard.c
@@ -30,11 +30,14 @@
#include "gimpbrush-private.h"
#include "gimpbrushclipboard.h"
#include "gimpimage.h"
+#include "gimppickable.h"
#include "gimptempbuf.h"
#include "gimp-intl.h"
+#define BRUSH_MAX_SIZE 1024
+
enum
{
PROP_0,
@@ -92,7 +95,6 @@ gimp_brush_clipboard_class_init (GimpBrushClipboardClass *klass)
static void
gimp_brush_clipboard_init (GimpBrushClipboard *brush)
{
- brush->gimp = NULL;
}
static void
@@ -177,7 +179,8 @@ static void
gimp_brush_clipboard_changed (Gimp *gimp,
GimpBrush *brush)
{
- GimpBuffer *gimp_buffer;
+ GimpObject *paste;
+ GeglBuffer *buffer = NULL;
gint width;
gint height;
@@ -193,16 +196,25 @@ gimp_brush_clipboard_changed (Gimp *gimp,
brush->priv->pixmap = NULL;
}
- gimp_buffer = gimp_get_clipboard_buffer (gimp);
+ paste = gimp_get_clipboard_object (gimp);
+
+ if (GIMP_IS_IMAGE (paste))
+ {
+ gimp_pickable_flush (GIMP_PICKABLE (paste));
+ buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (paste));
+ }
+ else if (GIMP_IS_BUFFER (paste))
+ {
+ buffer = gimp_buffer_get_buffer (GIMP_BUFFER (paste));
+ }
- if (gimp_buffer)
+ if (buffer)
{
- GeglBuffer *buffer = gimp_buffer_get_buffer (gimp_buffer);
const Babl *format = gegl_buffer_get_format (buffer);
GeglBuffer *dest_buffer;
- width = MIN (gimp_buffer_get_width (gimp_buffer), 1024);
- height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
+ width = MIN (gegl_buffer_get_width (buffer), BRUSH_MAX_SIZE);
+ height = MIN (gegl_buffer_get_height (buffer), BRUSH_MAX_SIZE);
brush->priv->mask = gimp_temp_buf_new (width, height,
babl_format ("Y u8"));
diff --git a/app/core/gimppatternclipboard.c b/app/core/gimppatternclipboard.c
index 0ca30bc..932755a 100644
--- a/app/core/gimppatternclipboard.c
+++ b/app/core/gimppatternclipboard.c
@@ -35,6 +35,8 @@
#include "gimp-intl.h"
+#define PATTERN_MAX_SIZE 1024
+
enum
{
PROP_0,
@@ -92,7 +94,6 @@ gimp_pattern_clipboard_class_init (GimpPatternClipboardClass *klass)
static void
gimp_pattern_clipboard_init (GimpPatternClipboard *pattern)
{
- pattern->gimp = NULL;
}
static void
@@ -177,7 +178,8 @@ static void
gimp_pattern_clipboard_changed (Gimp *gimp,
GimpPattern *pattern)
{
- GimpBuffer *gimp_buffer;
+ GimpObject *paste;
+ GeglBuffer *buffer = NULL;
if (pattern->mask)
{
@@ -185,20 +187,27 @@ gimp_pattern_clipboard_changed (Gimp *gimp,
pattern->mask = NULL;
}
- gimp_buffer = gimp_get_clipboard_buffer (gimp);
+ paste = gimp_get_clipboard_object (gimp);
- if (gimp_buffer)
+ if (GIMP_IS_IMAGE (paste))
+ {
+ gimp_pickable_flush (GIMP_PICKABLE (paste));
+ buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (paste));
+ }
+ else if (GIMP_IS_BUFFER (paste))
{
- gint width;
- gint height;
+ buffer = gimp_buffer_get_buffer (GIMP_BUFFER (paste));
+ }
- width = MIN (gimp_buffer_get_width (gimp_buffer), 1024);
- height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
+ if (buffer)
+ {
+ gint width = MIN (gegl_buffer_get_width (buffer), PATTERN_MAX_SIZE);
+ gint height = MIN (gegl_buffer_get_height (buffer), PATTERN_MAX_SIZE);
pattern->mask = gimp_temp_buf_new (width, height,
- gimp_buffer_get_format (gimp_buffer));
+ gegl_buffer_get_format (buffer));
- gegl_buffer_get (gimp_buffer_get_buffer (gimp_buffer),
+ gegl_buffer_get (buffer,
GEGL_RECTANGLE (0, 0, width, height), 1.0,
NULL,
gimp_temp_buf_get_data (pattern->mask),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]