From: Øyvind Kolås Date: Tue, 28 May 2019 23:58:30 +0000 (+0200) Subject: babl: implement babl_space_get_rgb_luminance X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~110 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b60b394cb86e91397c2e4d8563a0a4e2e9c550ba;p=babl.git babl: implement babl_space_get_rgb_luminance 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. --- diff --git a/babl/babl-space.c b/babl/babl-space.c index f64ca3b..da6ac67 100644 --- a/babl/babl-space.c +++ b/babl/babl-space.c @@ -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]; +} diff --git a/babl/babl.h b/babl/babl.h index 8e71fac..bba5873 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -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: diff --git a/export-symbols b/export-symbols index c0dff8f..d692f46 100644 --- a/export-symbols +++ b/export-symbols @@ -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