[gegl] Pixelize: Don't add Alpha to a RGB input
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Pixelize: Don't add Alpha to a RGB input
- Date: Thu, 18 Apr 2013 01:09:11 +0000 (UTC)
commit bdb32be72d85397ee3dbc762db57ed5afa27f6f6
Author: Daniel Sabo <DanielSabo gmail com>
Date: Wed Apr 17 17:26:05 2013 -0700
Pixelize: Don't add Alpha to a RGB input
operations/common/pixelize.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/operations/common/pixelize.c b/operations/common/pixelize.c
index 4292b8c..5513a97 100644
--- a/operations/common/pixelize.c
+++ b/operations/common/pixelize.c
@@ -46,6 +46,8 @@ static void prepare (GeglOperation *operation)
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
+ const Babl *source_format = gegl_operation_get_source_format (operation, "input");
+
op_area->left =
op_area->right = o->size_x;
op_area->top =
@@ -53,8 +55,11 @@ static void prepare (GeglOperation *operation)
gegl_operation_set_format (operation, "input",
babl_format ("RaGaBaA float"));
- gegl_operation_set_format (operation, "output",
- babl_format ("RaGaBaA float"));
+
+ if (source_format && !babl_format_has_alpha (source_format))
+ gegl_operation_set_format (operation, "output", babl_format ("RGB float"));
+ else
+ gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
}
static void
@@ -221,17 +226,18 @@ cl_process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *roi)
{
- const Babl *in_format = gegl_operation_get_format (operation, "input");
- const Babl *out_format = gegl_operation_get_format (operation, "output");
+ const Babl *in_format = babl_format ("RaGaBaA float");
+ const Babl *out_format = babl_format ("RaGaBaA float");
+ gboolean has_alpha = babl_format_has_alpha (gegl_operation_get_format (operation, "output"));
+ GeglAbyssPolicy read_abyss = has_alpha ? GEGL_ABYSS_NONE : GEGL_ABYSS_BLACK;
gint err;
- cl_int cl_err;
gint j;
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBufferClIterator *i = gegl_buffer_cl_iterator_new (output, roi, out_format, GEGL_CL_BUFFER_WRITE);
- gint read = gegl_buffer_cl_iterator_add_2 (i, input, roi, in_format, GEGL_CL_BUFFER_READ,
op_area->left, op_area->right, op_area->top, op_area->bottom, GEGL_ABYSS_NONE);
+ gint read = gegl_buffer_cl_iterator_add_2 (i, input, roi, in_format, GEGL_CL_BUFFER_READ,
op_area->left, op_area->right, op_area->top, op_area->bottom, read_abyss);
gint aux = gegl_buffer_cl_iterator_add_2 (i, NULL, roi, in_format, GEGL_CL_BUFFER_AUX,
op_area->left, op_area->right, op_area->top, op_area->bottom, GEGL_ABYSS_NONE);
while (gegl_buffer_cl_iterator_next (i, &err))
{
@@ -239,7 +245,7 @@ cl_process (GeglOperation *operation,
for (j=0; j < i->n; j++)
{
err = cl_pixelise(i->tex[read][j], i->tex[aux][j], i->tex[0][j],&i->roi[read][j], &i->roi[0][j],
o->size_x, o->size_y);
- if (cl_err != CL_SUCCESS)
+ if (err != CL_SUCCESS)
{
g_warning("[OpenCL] Error in gegl:pixelize");
return FALSE;
@@ -260,6 +266,8 @@ process (GeglOperation *operation,
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglOperationAreaFilter *op_area;
gfloat* buf;
+ gboolean has_alpha = babl_format_has_alpha (gegl_operation_get_format (operation, "output"));
+ GeglAbyssPolicy read_abyss = has_alpha ? GEGL_ABYSS_NONE : GEGL_ABYSS_BLACK;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
src_rect = *roi;
@@ -274,7 +282,7 @@ process (GeglOperation *operation,
buf = g_new0 (gfloat, src_rect.width * src_rect.height * 4);
- gegl_buffer_get (input, &src_rect, 1.0, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE,
GEGL_ABYSS_NONE);
+ gegl_buffer_get (input, &src_rect, 1.0, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE,
read_abyss);
pixelize(buf, roi, o->size_x, o->size_y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]