babl: implement babl_space_get_rgb_luminance
authorØyvind Kolås <pippin@gimp.org>
Tue, 28 May 2019 23:58:30 +0000 (01:58 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 28 May 2019 23:58:35 +0000 (01:58 +0200)
This provides the factors often found as defines hard-coded for sRGB
with values that are adapted to the primaries of the RGB family of
pixel encodings for a given babl space.

babl/babl-space.c
babl/babl.h
export-symbols

index f64ca3baba5ba8c68cab28c7e26a50ae432562ac..da6ac67bdf173b0ec126d2ca3cd35848cdbb1ec9 100644 (file)
@@ -1230,3 +1230,19 @@ babl_space_get_XYZtoRGB (const Babl *space)
    return &space->space.XYZtoRGB[0];
 }
 
+
+void
+babl_space_get_rgb_luminance (const Babl *space,
+                              double     *red_luminance,
+                              double     *green_luminance,
+                              double     *blue_luminance)
+{
+  if (!space)
+    space = babl_space ("sRGB");
+  if (red_luminance)
+    *red_luminance = space->space.RGBtoXYZ[3];
+  if (green_luminance)
+    *green_luminance = space->space.RGBtoXYZ[4];
+  if (blue_luminance)
+    *blue_luminance = space->space.RGBtoXYZ[5];
+}
index 8e71fac6fc258b1f5149400b93a381d5e0dfe361..bba5873e953a72c5bfda8af7857b431c44fdd226 100644 (file)
@@ -585,6 +585,20 @@ babl_space_get_RGBtoXYZ (const Babl *space);
 const double *
 babl_space_get_XYZtoRGB (const Babl *space);
 
+/**
+ * babl_space_get_rgb_luminance:
+ * @space: a BablSpace
+ * @red_luminance: pointer to a double where red luminance factor is stored
+ * @green_luminance: pointer to a double where green luminance factor is stored
+ * @blue_luminance: pointer to a double where blue luminance factor is stored
+ *
+ * Retrieve the relevant RGB luminance constants for a babl space.
+ */
+void
+babl_space_get_rgb_luminance (const Babl *space,
+                              double     *red_luminance,
+                              double     *green_luminance,
+                              double     *blue_luminance);
 
 /**
  * babl_model_is:
index c0dff8f345a7d494b955db089f2e3f470f3630ca..d692f46d78a081eafbdd3151298687fe28151e85 100644 (file)
@@ -47,8 +47,9 @@ babl_space_from_rgbxyz_matrix
 babl_space_from_chromaticities
 babl_space_from_icc
 babl_space_get
-babl_space_get_rgbtoxyz
 babl_space_get_icc
+babl_space_get_rgbtoxyz
+babl_space_get_rgb_luminance
 babl_space_to_xyz
 babl_space_from_xyz
 babl_space_to_icc