[gnome-color-manager] trivial: scale the computed RGB values to 1.0
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: scale the computed RGB values to 1.0
- Date: Mon, 28 Nov 2011 21:35:54 +0000 (UTC)
commit 027d8abf3208552e4337623c6e38c5fdada3bf4c
Author: Richard Hughes <richard hughsie com>
Date: Mon Nov 28 21:21:38 2011 +0000
trivial: scale the computed RGB values to 1.0
src/gcm-calibrate.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index 884a6a9..eadddd2 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -1123,6 +1123,40 @@ gcm_calibrate_array_remove_offset (GPtrArray *array)
}
/**
+ * gcm_calibrate_array_scale:
+ **/
+static void
+gcm_calibrate_array_scale (GPtrArray *array, gdouble value)
+{
+ CdColorRGB *rgb;
+ CdColorRGB scale;
+ guint i;
+
+ /* scale all values */
+ cd_color_set_rgb (&scale,
+ G_MINDOUBLE,
+ G_MINDOUBLE,
+ G_MINDOUBLE);
+ for (i = 0; i < array->len; i++) {
+ rgb = g_ptr_array_index (array, i);
+ if (rgb->R > scale.R)
+ scale.R = rgb->R;
+ if (rgb->G > scale.G)
+ scale.G = rgb->G;
+ if (rgb->B > scale.B)
+ scale.B = rgb->B;
+ }
+ for (i = 0; i < array->len; i++) {
+ rgb = g_ptr_array_index (array, i);
+ rgb->R /= scale.R;
+ rgb->G /= scale.G;
+ rgb->B /= scale.B;
+ }
+ g_debug ("scaled to 1.0 using = %f,%f,%f",
+ scale.R, scale.G, scale.B);
+}
+
+/**
* gcm_calibrate_display_calibration:
**/
gboolean
@@ -1206,6 +1240,9 @@ gcm_calibrate_display_calibration (GcmCalibrate *calibrate,
/* bias the values to zero */
gcm_calibrate_array_remove_offset (results_rgb);
+ /* scale the largest number to 1.0 */
+ gcm_calibrate_array_scale (results_rgb, 1.0f);
+
out:
if (samples_rgb != NULL)
g_ptr_array_unref (samples_rgb);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]