[gegl] Added an op that can be used to fix a wrongly premultiplied buffer.
- From: Øyvind Kolås <ok src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl] Added an op that can be used to fix a wrongly premultiplied buffer.
- Date: Tue, 10 Nov 2009 02:29:25 +0000 (UTC)
commit 93534cb3227f66d041290076310492ea8dbc8790
Author: �yvind Kolås <pippin gimp org>
Date: Tue Nov 10 02:27:11 2009 +0000
Added an op that can be used to fix a wrongly premultiplied buffer.
This is a hack, that probably shall remain in the workshop.
operations/workshop/unpremul.c | 76 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/operations/workshop/unpremul.c b/operations/workshop/unpremul.c
new file mode 100644
index 0000000..6d6883b
--- /dev/null
+++ b/operations/workshop/unpremul.c
@@ -0,0 +1,76 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2006 �yvind Kolås <pippin gimp org>
+ */
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+ /* no properties */
+
+#else
+
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "unpremul.c"
+#define GEGLV4
+
+#include "gegl-chant.h"
+
+static gboolean
+process (GeglOperation *op,
+ void *in_buf,
+ void *out_buf,
+ glong samples,
+ const GeglRectangle *roi)
+{
+ glong i;
+ gfloat *in = in_buf;
+ gfloat *out = out_buf;
+
+ for (i=0; i<samples; i++)
+ {
+ int j;
+ for (j=0; j<3; j++)
+ {
+ if (in[3] != 0)
+ out[j] = in[j] / in[3];
+ else
+ out[j] = 0.0;
+ }
+ out[3]=in[3];
+ in += 4;
+ out+= 4;
+ }
+ return TRUE;
+}
+
+
+static void
+gegl_chant_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ point_filter_class->process = process;
+
+ operation_class->name = "gegl:unpremul";
+ operation_class->categories = "color";
+ operation_class->description = "Unpremultiplies a buffer that contains pre-multiplied colors (but is marked as not having it)";
+}
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]