babl: fix some annotation to make the function usable in bindings.
[babl.git] / tests / xyz_to_lab.c
blobc8e0b81e17c932a11a0a0f20d2665ecca6984201
1 /* babl - dynamically extendable universal pixel conversion library.
2 * Copyright (C) 2005, Øyvind Kolås.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see
16 * <https://www.gnu.org/licenses/>.
19 #include <math.h>
20 #include <babl/babl.h>
21 #include <stdio.h>
23 #define PIXELS 4
24 #define TOLERANCE 0.05
26 float source_buf [PIXELS * 3] =
27 { 0.950, 1.000, 1.089,
28 1.000, 0.000, 0.000,
29 0.000, 1.000, 0.000,
30 0.000, 0.000, 1.000
33 float reference_buf [PIXELS * 3] =
34 { 100.00, -2.467186, -19.400648,
35 0.0, 437.147125, 0.0,
36 100.0, -431.034485, 172.4137,
37 0.0, 0.0, -185.6406,
40 float destination_buf [PIXELS * 3];
42 static int
43 test (void)
45 int i;
46 int OK = 1;
48 babl_process (babl_fish ("CIE XYZ float", "CIE Lab float"),
49 source_buf, destination_buf,
50 PIXELS);
52 for (i = 0; i < PIXELS * 3; i++)
54 if (fabs (1.0 * destination_buf[i] - reference_buf[i]) > TOLERANCE)
56 fprintf (stderr, "%2i (component: %2i%%3=%i, test no: %2i/3=%i) is %f should be %f\n",
57 i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]);
58 OK = 0;
61 if (!OK)
62 return -1;
63 return 0;
66 int
67 main (void)
69 babl_init ();
70 if (test ())
71 return -1;
72 babl_exit ();
73 return 0;