Commit a302056f authored by Øyvind Kolås's avatar Øyvind Kolås

added blank and checkerboard ops

parent 5787aa67
2006-08-16 Øyvind Kolås <pippin@gimp.org>
Added two ops, one that renders a black/white checkerboard with
specified horizonal/vertical spacings for the cells, and one that
generates a blank image.
* operations/render/blank.c,
* operations/render/checkerboard.c: New files.
2006-08-16 Øyvind Kolås <pippin@gimp.org>
Fixed aux format request in point composers.
......
/* This file is an image processing operation for GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#ifdef CHANT_SELF
#else
#define CHANT_SOURCE
#define CHANT_NAME blank
#define CHANT_DESCRIPTION "Blank Source"
#define CHANT_SELF "blank.c"
#define CHANT_CATEGORIES "sources"
#include "gegl-chant.h"
static gboolean
evaluate (GeglOperation *operation,
const gchar *output_prop)
{
GeglRect *need;
GeglOperationSource *op_source = GEGL_OPERATION_SOURCE(operation);
if(strcmp("output", output_prop))
return FALSE;
if (op_source->output)
g_object_unref (op_source->output);
op_source->output=NULL;
need = gegl_operation_need_rect (operation);
{
GeglRect *result = gegl_operation_result_rect (operation);
gfloat *buf;
op_source->output = g_object_new (GEGL_TYPE_BUFFER,
"format",
babl_format ("YA float"),
"x", result->x,
"y", result->y,
"width", result->w,
"height", result->h,
NULL);
buf = g_malloc0 (gegl_buffer_pixels (op_source->output) * gegl_buffer_px_size (op_source->output));
gegl_buffer_set (op_source->output, buf);
g_free (buf);
}
return TRUE;
}
static gboolean
calc_have_rect (GeglOperation *operation)
{
gegl_operation_set_have_rect (operation, -1000000, -1000000, 2000000, 2000000);
return TRUE;
}
#endif
/* This file is an image processing operation for GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#ifdef CHANT_SELF
chant_int (x, -G_MAXINT, G_MAXINT, 16, "")
chant_int (y, -G_MAXINT, G_MAXINT, 16, "")
chant_int (x_offset, -G_MAXINT, G_MAXINT, 0, "")
chant_int (y_offset, -G_MAXINT, G_MAXINT, 0, "")
#else
#define CHANT_SOURCE
#define CHANT_NAME checkerboard
#define CHANT_DESCRIPTION "Black and white checkerboard renderer."
#define CHANT_SELF "checkerboard.c"
#define CHANT_CATEGORIES "sources:render"
#include "gegl-chant.h"
static gboolean
evaluate (GeglOperation *operation,
const gchar *output_prop)
{
GeglRect *need;
GeglOperationSource *op_source = GEGL_OPERATION_SOURCE(operation);
ChantInstance *self = CHANT_INSTANCE (operation);
if(strcmp("output", output_prop))
return FALSE;
if (op_source->output)
g_object_unref (op_source->output);
op_source->output=NULL;
need = gegl_operation_need_rect (operation);
{
GeglRect *result = gegl_operation_result_rect (operation);
gfloat *buf;
op_source->output = g_object_new (GEGL_TYPE_BUFFER,
"format",
babl_format ("Y float"),
"x", result->x,
"y", result->y,
"width", result->w,
"height", result->h,
NULL);
buf = g_malloc (gegl_buffer_pixels (op_source->output) * gegl_buffer_px_size (op_source->output));
{
gfloat *dst=buf;
gint y;
for (y=0; y < result->h; y++)
{
gint x;
for (x=0; x < result->w; x++)
{
gfloat val;
gint nx,ny;
nx = (x + result->x + self->x_offset)/self->x;
ny = (y + result->y + self->y_offset)/self->y;
if ( (nx%2) == 0 )
{
if ((ny%2)==0)
{
val = 0.0;
}
else
{
val = 1.0;
}
}
else
{
if ((ny%2)==0)
{
val = 1.0;
}
else
{
val = 0.0;
}
}
*dst = val;
dst ++;
}
}
}
gegl_buffer_set (op_source->output, buf);
g_free (buf);
}
return TRUE;
}
static gboolean
calc_have_rect (GeglOperation *operation)
{
/*OpNoise *self = (OpNoise*)(operation);*/
gegl_operation_set_have_rect (operation, -1000000, -1000000, 2000000, 2000000);
return TRUE;
}
#endif
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