[babl] babl: add babl_space_with_trc



commit 4320b2f37876a54276e9f4ad98bd22fc524bcdbd
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 18 22:05:27 2018 +0200

    babl: add babl_space_with_trc
    
    Permitting to create variants of a space that shared the primaries
    but use a different TRC function.

 babl/babl-space.c | 20 ++++++++++++++++++++
 babl/babl.h       |  9 ++++++++-
 export-symbols    |  1 +
 3 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/babl/babl-space.c b/babl/babl-space.c
index 482a21c..9a78d38 100644
--- a/babl/babl-space.c
+++ b/babl/babl-space.c
@@ -1034,6 +1034,26 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
   return NULL;
 }
 
+const Babl *babl_space_with_trc (const Babl *babl, const Babl *trc)
+{
+  double xw, yw, xr, yr, xg, yg, xb, yb;
+  const Babl *red_trc = NULL;
+  const Babl *green_trc = NULL;
+  const Babl *blue_trc = NULL;
+
+  babl_space_get (babl,
+                  &xw, &yw,
+                  &xr, &yr,
+                  &xg, &yg,
+                  &xb, &yb,
+                  &red_trc, &green_trc, &blue_trc);
+  if (red_trc == trc && green_trc == trc && blue_trc == trc)
+    return babl;
+  return babl_space_from_chromaticities (NULL,
+                                         xw, yw, xr, yr, xg, yg, xb, yb, trc, trc, trc,
+                                         BABL_SPACE_FLAG_EQUALIZE);
+
+}
 
 void babl_space_get (const Babl *babl,
                      double *xw, double *yw,
diff --git a/babl/babl.h b/babl/babl.h
index 9516024..6d58aac 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -506,12 +506,19 @@ const Babl * babl_trc_gamma (double gamma);
 /**
  * babl_trc:
  *
- * Look up a TRC by name, "sRGB" "1.0" "linear" and "2.2" are recognized
+ * Look up a TRC by name, "sRGB" and "linear" are recognized
  * strings in a stock babl configuration.
  */
 const Babl * babl_trc (const char *name);
 
 
+/**
+ * babl_space_with_trc:
+ *
+ * Creates a variant of an existing space with different trc.
+ */
+const Babl *babl_space_with_trc (const Babl *space, const Babl *trc);
+
 /**
  * babl_space_get:
  *
diff --git a/export-symbols b/export-symbols
index be9d4c6..d246e3d 100644
--- a/export-symbols
+++ b/export-symbols
@@ -49,6 +49,7 @@ babl_space_get_icc
 babl_space_to_xyz
 babl_space_from_xyz
 babl_space_to_icc
+babl_space_with_trc
 babl_icc_make_space
 babl_icc_get_key
 babl_ticks


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