|
Packit Service |
2781ba |
/*
|
|
Packit Service |
2781ba |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
2781ba |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
2781ba |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
2781ba |
* (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
2781ba |
* GNU General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
2781ba |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright (C) 2009 Martin Nordholts
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define RED 0
|
|
Packit Service |
2781ba |
#define GREEN 1
|
|
Packit Service |
2781ba |
#define BLUE 2
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define SUCCESS 0
|
|
Packit Service |
2781ba |
#define FAILURE -1
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define RUNS 3
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
int main(int argc, char *argv[])
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
int result = SUCCESS;
|
|
Packit Service |
2781ba |
guchar result_buffer[3] = { 0, 0, 0 };
|
|
Packit Service |
2781ba |
int i = 0;
|
|
Packit Service |
2781ba |
GeglNode *color = NULL;
|
|
Packit Service |
2781ba |
GeglColor *colors[RUNS] = { 0, 0, 0 };
|
|
Packit Service |
2781ba |
guchar expected_results[RUNS][3] = { { 255, 0, 0 },
|
|
Packit Service |
2781ba |
{ 0, 255, 0 },
|
|
Packit Service |
2781ba |
{ 0, 0, 255 } };
|
|
Packit Service |
2781ba |
GeglRectangle rois[RUNS] = { { 0, 0, 1, 1 },
|
|
Packit Service |
2781ba |
{ G_MININT / 2, G_MININT / 2, 1, 1 },
|
|
Packit Service |
2781ba |
{ G_MAXINT / 2 - 1, G_MAXINT / 2 - 1, 1, 1 } };
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* Init */
|
|
Packit Service |
2781ba |
g_thread_init (NULL);
|
|
Packit Service |
2781ba |
gegl_init (&argc, &argv);
|
|
Packit Service |
2781ba |
colors[0] = gegl_color_new ("rgb(1.0, 0.0, 0.0)");
|
|
Packit Service |
2781ba |
colors[1] = gegl_color_new ("rgb(0.0, 1.0, 0.0)");
|
|
Packit Service |
2781ba |
colors[2] = gegl_color_new ("rgb(0.0, 0.0, 1.0)");
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* Construct graph */
|
|
Packit Service |
2781ba |
color = gegl_node_new_child (NULL,
|
|
Packit Service |
2781ba |
"operation", "gegl:color",
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* Run tests */
|
|
Packit Service |
2781ba |
for (i = 0; i < RUNS; i++)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gegl_node_set (color,
|
|
Packit Service |
2781ba |
"value", colors[i],
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
memset (result_buffer, 0, sizeof (result_buffer));
|
|
Packit Service |
2781ba |
gegl_node_blit (color,
|
|
Packit Service |
2781ba |
1.0,
|
|
Packit Service |
2781ba |
&rois[i],
|
|
Packit Service |
2781ba |
babl_format ("RGB u8"),
|
|
Packit Service |
2781ba |
result_buffer,
|
|
Packit Service |
2781ba |
GEGL_AUTO_ROWSTRIDE,
|
|
Packit Service |
2781ba |
GEGL_BLIT_DEFAULT);
|
|
Packit Service |
2781ba |
if (!(result_buffer[RED] == expected_results[i][RED] &&
|
|
Packit Service |
2781ba |
result_buffer[GREEN] == expected_results[i][GREEN] &&
|
|
Packit Service |
2781ba |
result_buffer[BLUE] == expected_results[i][BLUE]))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
result = FAILURE;
|
|
Packit Service |
2781ba |
g_printerr ("Processing #%d of gegl:color failed", i + 1);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* Cleanup */
|
|
Packit Service |
2781ba |
g_object_unref (color);
|
|
Packit Service |
2781ba |
for (i = 0; i < RUNS; i++)
|
|
Packit Service |
2781ba |
g_object_unref (colors[i]);
|
|
Packit Service |
2781ba |
gegl_exit ();
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return result;
|
|
Packit Service |
2781ba |
}
|