mirror of https://github.com/GNOME/gimp.git
app: support clipboard images in the clipboard brush and pattern
This commit is contained in:
parent
c2f0226f66
commit
6eeb5c2ee2
|
@ -30,11 +30,14 @@
|
||||||
#include "gimpbrush-private.h"
|
#include "gimpbrush-private.h"
|
||||||
#include "gimpbrushclipboard.h"
|
#include "gimpbrushclipboard.h"
|
||||||
#include "gimpimage.h"
|
#include "gimpimage.h"
|
||||||
|
#include "gimppickable.h"
|
||||||
#include "gimptempbuf.h"
|
#include "gimptempbuf.h"
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BRUSH_MAX_SIZE 1024
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -92,7 +95,6 @@ gimp_brush_clipboard_class_init (GimpBrushClipboardClass *klass)
|
||||||
static void
|
static void
|
||||||
gimp_brush_clipboard_init (GimpBrushClipboard *brush)
|
gimp_brush_clipboard_init (GimpBrushClipboard *brush)
|
||||||
{
|
{
|
||||||
brush->gimp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -177,7 +179,8 @@ static void
|
||||||
gimp_brush_clipboard_changed (Gimp *gimp,
|
gimp_brush_clipboard_changed (Gimp *gimp,
|
||||||
GimpBrush *brush)
|
GimpBrush *brush)
|
||||||
{
|
{
|
||||||
GimpBuffer *gimp_buffer;
|
GimpObject *paste;
|
||||||
|
GeglBuffer *buffer = NULL;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
|
@ -193,16 +196,25 @@ gimp_brush_clipboard_changed (Gimp *gimp,
|
||||||
brush->priv->pixmap = NULL;
|
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);
|
const Babl *format = gegl_buffer_get_format (buffer);
|
||||||
GeglBuffer *dest_buffer;
|
GeglBuffer *dest_buffer;
|
||||||
|
|
||||||
width = MIN (gimp_buffer_get_width (gimp_buffer), 1024);
|
width = MIN (gegl_buffer_get_width (buffer), BRUSH_MAX_SIZE);
|
||||||
height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
|
height = MIN (gegl_buffer_get_height (buffer), BRUSH_MAX_SIZE);
|
||||||
|
|
||||||
brush->priv->mask = gimp_temp_buf_new (width, height,
|
brush->priv->mask = gimp_temp_buf_new (width, height,
|
||||||
babl_format ("Y u8"));
|
babl_format ("Y u8"));
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define PATTERN_MAX_SIZE 1024
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -92,7 +94,6 @@ gimp_pattern_clipboard_class_init (GimpPatternClipboardClass *klass)
|
||||||
static void
|
static void
|
||||||
gimp_pattern_clipboard_init (GimpPatternClipboard *pattern)
|
gimp_pattern_clipboard_init (GimpPatternClipboard *pattern)
|
||||||
{
|
{
|
||||||
pattern->gimp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -177,7 +178,8 @@ static void
|
||||||
gimp_pattern_clipboard_changed (Gimp *gimp,
|
gimp_pattern_clipboard_changed (Gimp *gimp,
|
||||||
GimpPattern *pattern)
|
GimpPattern *pattern)
|
||||||
{
|
{
|
||||||
GimpBuffer *gimp_buffer;
|
GimpObject *paste;
|
||||||
|
GeglBuffer *buffer = NULL;
|
||||||
|
|
||||||
if (pattern->mask)
|
if (pattern->mask)
|
||||||
{
|
{
|
||||||
|
@ -185,20 +187,27 @@ gimp_pattern_clipboard_changed (Gimp *gimp,
|
||||||
pattern->mask = NULL;
|
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;
|
gimp_pickable_flush (GIMP_PICKABLE (paste));
|
||||||
gint height;
|
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);
|
if (buffer)
|
||||||
height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
|
{
|
||||||
|
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,
|
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,
|
GEGL_RECTANGLE (0, 0, width, height), 1.0,
|
||||||
NULL,
|
NULL,
|
||||||
gimp_temp_buf_get_data (pattern->mask),
|
gimp_temp_buf_get_data (pattern->mask),
|
||||||
|
|
Loading…
Reference in New Issue