[gegl/soc-2011-ops] Added cubism op, no improvement
- From: Robert Sasu <sasurobert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/soc-2011-ops] Added cubism op, no improvement
- Date: Wed, 6 Jul 2011 19:47:50 +0000 (UTC)
commit 9b97ac4f17048629b2e9609ce0c8640e47cecf62
Author: Robert Sasu <sasu robert gmail com>
Date: Wed Jul 6 22:46:20 2011 +0300
Added cubism op, no improvement
operations/workshop/cubism.c | 113 ++++++++++++++++++++++++++++++++++--------
1 files changed, 92 insertions(+), 21 deletions(-)
---
diff --git a/operations/workshop/cubism.c b/operations/workshop/cubism.c
index 9620f7e..f6ba2b3 100644
--- a/operations/workshop/cubism.c
+++ b/operations/workshop/cubism.c
@@ -52,7 +52,7 @@ gegl_chant_boolean (background, _("Background"), FALSE,
#define MAX_POINTS 4
#define RANDOMNESS 5
-
+FILE *f;
typedef struct
{
@@ -255,18 +255,16 @@ set_background_color (gfloat *dst_buf,
GeglBuffer *input,
const GeglRectangle *result)
{
- gint i, j, k, offset = 0;
+ gint i = 0, j, k, offset = 0, area = 0;
GeglRectangle tmp;
gfloat *tmp_buf;
tmp.x = extended->x;
tmp.y = extended->y;
tmp.width = extended->width;
- tmp.height = result->y - extended->y;
-
+ tmp.height = 2 * (result->y - extended->y);
/*get previously calculated pixels*/
-
/*top*/
if (tmp.height)
{
@@ -275,14 +273,27 @@ set_background_color (gfloat *dst_buf,
GEGL_AUTO_ROWSTRIDE);
for (i=0; i<tmp.width * tmp.height * 4; i++)
+ {
dst_buf[i] = tmp_buf[i];
+ }
g_free (tmp_buf);
- }
-
- tmp.y = result->y;
- tmp.width = result->x - extended->x;
- tmp.height = extended->height - (result->y - extended->y);
+ area += 1;
+ }
+
+ if (area!=0)
+ {
+ tmp.y = result->y + (result->y - extended->y);
+ tmp.width = 2 * (result->x - extended->x);
+ tmp.height = extended->height - 2 * (result->y - extended->y);
+ }
+ else
+ {
+ tmp.y = result->y;
+ tmp.width = 2 * (result->x - extended->x);
+ tmp.height = extended->height - (result->y - extended->y);
+ }
+
/*left*/
if (tmp.width)
{
@@ -290,24 +301,83 @@ set_background_color (gfloat *dst_buf,
gegl_buffer_get (input, 1.0, &tmp, babl_format ("RGBA float"), tmp_buf,
GEGL_AUTO_ROWSTRIDE);
- offset = (extended->width - 1) * (result->y - extended->y) * 4;
-
+ if (i!=0)
+ {
+ offset = (extended->width) * (result->y - extended->y - 1) * 4;
+ }
+ else
+ {
+ offset = (extended->width) * (2 * (result->y - extended->y) - 1) * 4;
+ }
+
for (i=0; i<tmp.height; i++)
{
offset += (extended->width * 4);
for (j=0; j< tmp.width * 4; j++)
- dst_buf[offset++] = tmp_buf[i];
+ {
+ dst_buf[offset++] = tmp_buf[i * tmp.width * 4 + j];
+ }
}
g_free (tmp_buf);
+
+ area += 2;
+ }
+
+ switch (area) /*no top, neither bottom*/
+ {
+ case 0:
+ k = 0;
+ for (i=0; i < extended->height * extended->width * 4; i++)
+ {
+ dst_buf[i] = color[k++];
+ if (k % 4 == 0) k = 0;
+ }
+ break;
+
+ case 1: /*just top*/
+
+ for (i=2 * result->y - extended->y; i < extended->height; i++)
+ {
+ offset = ((i - extended->y) * extended->width + result->x - extended->x) * 4;
+ for (j=result->x; j<extended->width; j++)
+ for (k=0; k<4; k++)
+ dst_buf[offset++] = color[k];
+ }
+ break;
+
+ case 2: /*just left*/
+
+ for (i=result->y; i < extended->height; i++)
+ {
+ offset = ((i - extended->y) * extended->width + 2 * (result->x - extended->x)) * 4;
+ for (j=2 * result->x - extended->x; j<extended->width; j++)
+ for (k=0; k<4; k++)
+ dst_buf[offset++] = color[k];
+ }
+ break;
+
+ case 3: /*top and left*/
+
+ for (i=2 * result->y - extended->y; i < extended->height; i++)
+ {
+ offset = ((i - extended->y) * extended->width + 2 * (result->x - extended->x)) * 4;
+ for (j=2 * result->x - extended->x; j<extended->width; j++)
+ for (k=0; k<4; k++)
+ dst_buf[offset++] = color[k];
+ }
+ break;
}
- for (i=result->y; i < extended->height; i++)
- {
- offset = ((i - extended->y) * extended->width + result->x - extended->x) * 4;
- for (j=result->x; j<extended->width; j++)
- for (k=0; k<4; k++)
- dst_buf[offset++] = color[k];
- }
+
+
+ /*
+ for (i=0; i<extended->height * extended->width * 4;i++)
+ {
+ if (dst_buf[i]!=0) fprintf(f,"\t %d %lf ",i, dst_buf[i]);
+
+ if (dst_buf[i]!=0 && (i+1) % 4 == 0) fprintf(f,"\n");
+ }*/
+// fprintf(f,"\n\n");
}
static void
@@ -564,7 +634,7 @@ process (GeglOperation *operation,
cols = (result->width + o->tile_size - 1) / o->tile_size;
rows = (result->height + o->tile_size - 1) / o->tile_size;
- set_background_color (dst_buf, &extended, bg_col, input, result);
+ // set_background_color (dst_buf, &extended, bg_col, input, result);
num_tiles = (rows + 1) * (cols + 1);
@@ -676,6 +746,7 @@ gegl_chant_class_init (GeglChantClass *klass)
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
+ f = fopen ("tryyy","w+t");
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]