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

This commit is contained in:
Michael Natterer 2012-03-17 21:59:10 +01:00
parent 733a98d33b
commit 69b2aa880f
8 changed files with 38 additions and 29 deletions

View File

@ -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);

View File

@ -41,6 +41,8 @@
#define _O_BINARY 0
#endif
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"

View File

@ -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);
}

View File

@ -52,6 +52,7 @@ GimpData * gimp_pattern_new (GimpContext *context,
GimpData * gimp_pattern_get_standard (GimpContext *context);
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
GeglBuffer * gimp_pattern_create_buffer (const GimpPattern *pattern);
#endif /* __GIMP_PATTERN_H__ */

View File

@ -26,6 +26,7 @@
#undef GSEAL_ENABLE
#include <glib/gstdio.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -22,6 +22,7 @@
#undef GSEAL_ENABLE
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"