[gnome-color-manager] trivial: ensure calibration curve results are monotonic



commit 81d4def3dd8f273cb5cd745ba01d6fb20fed0d25
Author: Richard Hughes <richard hughsie com>
Date:   Mon Nov 28 21:29:43 2011 +0000

    trivial: ensure calibration curve results are monotonic

 src/gcm-calibrate.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index d0afa19..d0e93f9 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -1198,6 +1198,29 @@ gcm_calibrate_array_scale (GPtrArray *array, gdouble value)
 }
 
 /**
+ * gcm_calibrate_array_ensure_monotonic:
+ **/
+static void
+gcm_calibrate_array_ensure_monotonic (GPtrArray *array)
+{
+	CdColorRGB *rgb;
+	CdColorRGB *rgb_last;
+	guint i;
+
+	/* check each is going up compared to last reading */
+	for (i = 1; i <array->len; i++) {
+		rgb_last = g_ptr_array_index (array, i - 1);
+		rgb = g_ptr_array_index (array, i);
+		if (rgb->R < rgb_last->R)
+			rgb->R = rgb_last->R;
+		if (rgb->G < rgb_last->G)
+			rgb->G = rgb_last->G;
+		if (rgb->B < rgb_last->B)
+			rgb->B = rgb_last->B;
+	}
+}
+
+/**
  * gcm_calibrate_display_calibration:
  **/
 gboolean
@@ -1286,6 +1309,9 @@ gcm_calibrate_display_calibration (GcmCalibrate *calibrate,
 	/* scale the largest number to 1.0 */
 	gcm_calibrate_array_scale (results_rgb, 1.0f);
 
+	/* ensure results are monotonic */
+	gcm_calibrate_array_ensure_monotonic (results_rgb);
+
 	/* interpolate new array with correct size */
 	results_vcgt = g_ptr_array_new_with_free_func ((GDestroyNotify) cd_color_rgb_free);
 	gcm_calibrate_resize_results (results_rgb, results_vcgt, 256);



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