diff --git a/app/core/gimpbrushclipboard.c b/app/core/gimpbrushclipboard.c index 46fe5c429a..3f9df755cd 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_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)) + { + buffer = gimp_buffer_get_buffer (GIMP_BUFFER (paste)); + } + + 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 0ca30bc950..932755a92c 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)) { - gint width; - gint height; + 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)); + } - 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),