diff options
author | Richard Hughes <richard@hughsie.com> | 2014-11-17 13:20:07 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-11-17 13:28:28 +0000 |
commit | 4bbce955a4bfa145ac91ced10df7ddd1b835c6a6 (patch) | |
tree | 7a80754bc41ccb370bab9c38e2de633a82fc7640 | |
parent | 3386c63009500acb2da5cefbc5927f93ff33d165 (diff) | |
download | colord-4bbce955a4bfa145ac91ced10df7ddd1b835c6a6.tar.gz |
libcolord: Add cd_spectrum_get_value_raw()
-rw-r--r-- | lib/colord/cd-spectrum.c | 20 | ||||
-rw-r--r-- | lib/colord/cd-spectrum.h | 2 | ||||
-rw-r--r-- | lib/colord/cd-test-private.c | 5 |
3 files changed, 27 insertions, 0 deletions
diff --git a/lib/colord/cd-spectrum.c b/lib/colord/cd-spectrum.c index 6f6038b..472f49d 100644 --- a/lib/colord/cd-spectrum.c +++ b/lib/colord/cd-spectrum.c @@ -103,6 +103,26 @@ cd_spectrum_get_value (const CdSpectrum *spectrum, guint idx) } /** + * cd_spectrum_get_value_raw: + * @spectrum: a #CdSpectrum instance. + * @idx: an index into the data + * + * Gets the spectrum data at a specified index, without any normalization + * applied. Most people should use cd_spectrum_get_value() instead. + * + * Return value: spectral data value, or -1 for invalid + * + * Since: 1.2.6 + **/ +gdouble +cd_spectrum_get_value_raw (const CdSpectrum *spectrum, guint idx) +{ + g_return_val_if_fail (spectrum != NULL, -1.0f); + g_return_val_if_fail (idx < spectrum->data->len, -1.0f); + return g_array_index (spectrum->data, gdouble, idx); +} + +/** * cd_spectrum_get_wavelength: * @spectrum: a #CdSpectrum instance. * @idx: an index into the data diff --git a/lib/colord/cd-spectrum.h b/lib/colord/cd-spectrum.h index 46fb71b..ba853bd 100644 --- a/lib/colord/cd-spectrum.h +++ b/lib/colord/cd-spectrum.h @@ -52,6 +52,8 @@ gdouble cd_spectrum_get_norm (const CdSpectrum *spectrum); guint cd_spectrum_get_size (const CdSpectrum *spectrum); gdouble cd_spectrum_get_value (const CdSpectrum *spectrum, guint idx); +gdouble cd_spectrum_get_value_raw (const CdSpectrum *spectrum, + guint idx); gdouble cd_spectrum_get_wavelength (const CdSpectrum *spectrum, guint idx); gdouble cd_spectrum_get_value_for_nm (const CdSpectrum *spectrum, diff --git a/lib/colord/cd-test-private.c b/lib/colord/cd-test-private.c index bb36ee5..3449dd1 100644 --- a/lib/colord/cd-test-private.c +++ b/lib/colord/cd-test-private.c @@ -233,6 +233,11 @@ colord_spectrum_func (void) g_assert_cmpfloat (ABS (cd_spectrum_get_value (s, 2) - 1.333f), <, 0.001f); g_assert_cmpfloat (ABS (cd_spectrum_get_norm (s) - 1.333f), <, 0.001f); + /* test raw value */ + g_assert_cmpfloat (ABS (cd_spectrum_get_value_raw (s, 0) - 0.5f), <, 0.001f); + g_assert_cmpfloat (ABS (cd_spectrum_get_value_raw (s, 1) - 0.75f), <, 0.001f); + g_assert_cmpfloat (ABS (cd_spectrum_get_value_raw (s, 2) - 1.f), <, 0.001f); + cd_spectrum_free (s); } |