[gnome-color-manager] trivial: do not attempt to save the VGCT curves if they are not monotonic



commit 837be72605a6ebe85b4cf79f0edbe3d9339ba784
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 14 13:04:49 2010 +0100

    trivial: do not attempt to save the VGCT curves if they are not monotonic

 libcolor-glib/gcm-profile.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/libcolor-glib/gcm-profile.c b/libcolor-glib/gcm-profile.c
index cacd11b..e0c6a49 100644
--- a/libcolor-glib/gcm-profile.c
+++ b/libcolor-glib/gcm-profile.c
@@ -1335,9 +1335,15 @@ gcm_profile_set_vcgt_from_data (GcmProfile *profile, guint16 *red, guint16 *gree
 	if (priv->lcms_profile == NULL)
 		priv->lcms_profile = cmsCreateProfilePlaceholder (NULL);
 
-	/* print what we've got */
-	for (i=0; i<size; i++)
-		egg_debug ("VCGT%i = %i,%i,%i", i, red[i], green[i], blue[i]);
+	/* check monotonic */
+	for (i=0; i<size-1; i++) {
+		if (red[i] > red[i+1] ||
+		    green[i] > green[i+1] ||
+		    blue[i] > blue[i+1]) {
+			g_set_error_literal (error, 1, 0, "CVGT data not monotonic");
+			goto out;
+		}
+	}
 
 	/* build tone curve */
 	vcgt_curve[0] = cmsBuildTabulatedToneCurve16 (NULL, size, red);



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