Commit 69b2aa88 authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_pattern_create_buffer() and use it in gimp_edit_fill_internal()

parent 733a98d3
......@@ -570,7 +570,7 @@ gimp_edit_fill_internal (GimpImage *image,
break;
case GIMP_WHITE_FILL:
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
break;
case GIMP_PATTERN_FILL:
......@@ -593,22 +593,7 @@ gimp_edit_fill_internal (GimpImage *image,
if (pattern)
{
GeglBuffer *src_buffer;
GeglRectangle rect = { 0, };
gint pat_bytes;
rect.width = pattern->mask->width;
rect.height = pattern->mask->height;
pat_bytes = pattern->mask->bytes;
src_buffer =
gegl_buffer_linear_new_from_data (temp_buf_get_data (pattern->mask),
gimp_bpp_to_babl_format (pat_bytes,
TRUE),
&rect,
rect.width * pat_bytes,
NULL, NULL);
GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
gegl_buffer_set_pattern (dest_buffer, NULL, src_buffer, 0, 0);
......@@ -616,14 +601,9 @@ gimp_edit_fill_internal (GimpImage *image,
}
else
{
GeglColor *gegl_color;
GeglColor *gegl_color = gegl_color_new (NULL);
if (gimp_drawable_has_alpha (drawable))
gimp_rgb_set_alpha (&color, 1.0);
gegl_color = gegl_color_new (NULL);
gimp_gegl_color_set_rgba (gegl_color, &color);
gegl_buffer_set_color (dest_buffer, NULL, gegl_color);
g_object_unref (gegl_color);
......
......@@ -41,6 +41,8 @@
#define _O_BINARY 0
#endif
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
......
......@@ -19,7 +19,7 @@
#include <string.h>
#include <glib-object.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
......@@ -27,6 +27,8 @@
#include "base/temp-buf.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimppattern.h"
#include "gimppattern-load.h"
#include "gimptagged.h"
......@@ -263,3 +265,23 @@ gimp_pattern_get_mask (const GimpPattern *pattern)
return pattern->mask;
}
GeglBuffer *
gimp_pattern_create_buffer (const GimpPattern *pattern)
{
GeglRectangle rect = { 0, };
gint bytes;
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
rect.width = pattern->mask->width;
rect.height = pattern->mask->height;
bytes = pattern->mask->bytes;
return gegl_buffer_linear_new_from_data (temp_buf_get_data (pattern->mask),
gimp_bpp_to_babl_format (bytes, TRUE),
&rect,
rect.width * bytes,
NULL, NULL);
}
......@@ -45,13 +45,14 @@ struct _GimpPatternClass
};
GType gimp_pattern_get_type (void) G_GNUC_CONST;
GType gimp_pattern_get_type (void) G_GNUC_CONST;
GimpData * gimp_pattern_new (GimpContext *context,
const gchar *name);
GimpData * gimp_pattern_get_standard (GimpContext *context);
GimpData * gimp_pattern_new (GimpContext *context,
const gchar *name);
GimpData * gimp_pattern_get_standard (GimpContext *context);
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
GeglBuffer * gimp_pattern_create_buffer (const GimpPattern *pattern);
#endif /* __GIMP_PATTERN_H__ */
......@@ -26,6 +26,7 @@
#undef GSEAL_ENABLE
#include <glib/gstdio.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
......
......@@ -22,6 +22,7 @@
#undef GSEAL_ENABLE
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
......
......@@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......
......@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment