[gegl] buffer: add gegl_buffer_set_pattern
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: add gegl_buffer_set_pattern
- Date: Thu, 15 Mar 2012 23:01:58 +0000 (UTC)
commit 0ecb4423447429d80a1cede7e1ec519127f8f20b
Author: Ãyvind KolÃs <pippin gimp org>
Date: Thu Mar 15 23:01:03 2012 +0000
buffer: add gegl_buffer_set_pattern
gegl/buffer/gegl-buffer-access.c | 39 +++++++++++++++++++++++--------------
gegl/buffer/gegl-buffer.h | 20 +++++++++++++++++-
2 files changed, 42 insertions(+), 17 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 7ef486a..6c3771c 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -610,7 +610,6 @@ gegl_buffer_set (GeglBuffer *buffer,
#if 0
-
/*
* slow nearest neighbour resampler that seems to be
* completely correct.
@@ -1192,27 +1191,37 @@ gegl_buffer_clear (GeglBuffer *dst,
}
}
-#if 0
-/**
- * gegl_buffer_pattern:
- * @buffer: a #GeglBuffer
- * @roi: a rectangular region
- * @pattern: a #GeglBuffer to be repeated as a pattern
- * @x_offset: where the pattern starts horizontally
- * @y_offset: where the pattern starts vertical
- *
- * Clears the provided rectangular region by setting all the associated memory
- * to 0
- */
void gegl_buffer_set_pattern (GeglBuffer *buffer,
const GeglRectangle *rect,
GeglBuffer *pattern,
gdouble x_offset,
gdouble y_offset)
{
- /* NYI */
+ GeglRectangle src_rect = {0,}, dst_rect;
+ int pat_width, pat_height;
+ int cols, rows;
+ int col, row;
+ int width, height;
+
+ pat_width = gegl_buffer_get_width (pattern);
+ pat_height = gegl_buffer_get_height (pattern);
+ width = gegl_buffer_get_width (buffer);
+ height = gegl_buffer_get_height (buffer);
+
+ src_rect.width = dst_rect.width = pat_width;
+ src_rect.height = dst_rect.height = pat_height;
+
+ cols = width / pat_width + 1;
+ rows = height / pat_height + 1;
+
+ for (row = 0; row <= rows; row++)
+ for (col = 0; col <= cols; col++)
+ {
+ dst_rect.x = x_offset + (row-1) * pat_width;
+ dst_rect.y = y_offset + (col-1) * pat_height;
+ gegl_buffer_copy (pattern, &src_rect, buffer, &dst_rect);
+ }
}
-#endif
void gegl_buffer_set_color (GeglBuffer *dst,
const GeglRectangle *dst_rect,
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 3b653d8..cea1417 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -263,13 +263,29 @@ void gegl_buffer_set (GeglBuffer *buffer,
* @rect: a rectangular region to fill with a color.
* @color: the GeglColor to fill with.
*
- * Clears the provided rectangular region by setting all the associated memory
- * to 0
+ * Sets the region covered by rect to the specified color.
*/
void gegl_buffer_set_color (GeglBuffer *buffer,
const GeglRectangle *rect,
GeglColor *color);
+
+/**
+ * gegl_buffer_set_pattern:
+ * @buffer: a #GeglBuffer
+ * @roi: a rectangular region
+ * @pattern: a #GeglBuffer to be repeated as a pattern
+ * @x_offset: where the pattern starts horizontally
+ * @y_offset: where the pattern starts vertical
+ *
+ * Fill a region with a repeating pattern.
+ */
+void gegl_buffer_set_pattern (GeglBuffer *buffer,
+ const GeglRectangle *rect,
+ GeglBuffer *pattern,
+ gdouble x_offset,
+ gdouble y_offset);
+
/**
* gegl_buffer_get_format:
* @buffer: a #GeglBuffer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]