1 /* babl - dynamically extendable universal pixel conversion library.
2 * Copyright (C) 2005, 2017 Ø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/>.
21 #include "babl-internal.h"
23 #define TOLERANCE 0.001
26 float source_buf
[PIXELS
* 4] =
27 { 10.0, 1.0, 0.1, 1.0,
31 10.0, 1.0, 0.1, -0.01,
33 10.0, 1.0, 0.0001, 0.000001,
34 10.0, 1.0, 0.1 , -0.00001,
37 1000.0,10000.0, 100000.0, 0.001,
38 5000.0,50000.0, 500000.0, 0.01,
41 float bounce_buf
[PIXELS
* 4];
42 float destination_buf
[PIXELS
* 4];
50 babl_process (babl_fish ("RGBA float", "RaGaBaA float"),
51 source_buf
, bounce_buf
,
53 babl_process (babl_fish ("RaGaBaA float", "RGBA float"),
54 bounce_buf
, destination_buf
,
57 for (i
= 0; i
< PIXELS
; i
++)
59 for (int c
= 0; c
< 4; c
++)
61 if (fabs (destination_buf
[i
*4+c
] - source_buf
[i
*4+c
]) > TOLERANCE
)
63 babl_log ("separate alpha %i.%i: %.9f!=%.9f(ref) ", i
, c
, destination_buf
[i
*4+c
],
67 // fprintf (stdout, "%.19f ", destination_buf[i*4+c]);
69 // fprintf (stdout, "\n");
72 fprintf (stdout
, "\n");
74 babl_process (babl_fish ("RaGaBaA float", "RGBA float"),
75 source_buf
, bounce_buf
,
77 babl_process (babl_fish ("RGBA float", "RaGaBaA float"),
78 bounce_buf
, destination_buf
,
81 for (i
= 0; i
< PIXELS
; i
++)
83 for (int c
= 0; c
< 4; c
++)
85 if (fabs (destination_buf
[i
*4+c
] - source_buf
[i
*4+c
]) > TOLERANCE
)
87 babl_log ("associatd-alpha %i.%i: %.9f!=%.9f(ref) ", i
, c
, destination_buf
[i
*4+c
],
91 // fprintf (stdout, "%.19f ", destination_buf[i*4+c]);
93 // fprintf (stdout, "\n");