[babl] tests: add a test for naive CMYK conversion



commit 976fc36ac1e5661ed4f77ff83a275efeeadb27a4
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun May 3 12:13:14 2020 +0200

    tests: add a test for naive CMYK conversion

 tests/cmyk.c      | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |  1 +
 2 files changed, 57 insertions(+)
---
diff --git a/tests/cmyk.c b/tests/cmyk.c
new file mode 100644
index 000000000..3b11e449c
--- /dev/null
+++ b/tests/cmyk.c
@@ -0,0 +1,56 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ *
+ * This library 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.
+ *
+ * This library 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 this library; if not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include <babl/babl.h>
+
+#include "common.inc"
+
+
+int
+main (int    argc,
+      char **argv)
+{
+  int OK = 1;
+
+  float rgba[][4] = {{1.0     , 1.0     , 1.0     , 1.0},
+                     {0.0     , 1.0     , 0.0     , 1.0},
+                     {0.5     , 0.5     , 0.5     , 1.0},
+                     {0.0     , 1.0     , 1.0     , 1.0}};
+
+  float cmyk[][4] = {{0.0,       0.0  ,   0.0  , 0.0},
+                     {1.0,       0.0  ,   1.0  , 0.0},
+                     {0.0,       0.0  ,   0.0  , 0.5},
+                     {1.0,       0.0  ,   0.0  , 0.0}};
+
+  babl_init ();
+
+  CHECK_CONV_FLOAT ("rgba to cmyk ", float, 0.001,
+                    babl_format ("RGBA float"),
+                    babl_format ("CMYK float"),
+                    rgba, cmyk);
+
+  CHECK_CONV_FLOAT ("cmyk to rgba ", float, 0.001,
+                    babl_format ("CMYK float"),
+                    babl_format ("RGBA float"),
+                    cmyk, rgba);
+
+  babl_exit ();
+
+  return !OK;
+}
diff --git a/tests/meson.build b/tests/meson.build
index dfe7d4541..a656618d5 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -3,6 +3,7 @@ test_names = [
   'babl_class_name',
   'cairo_cmyk_hack',
   'cairo-RGB24',
+  'cmyk',
   'chromaticities',
   'extract',
   'floatclamp',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]