summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-08-13 08:39:46 +0100
committerRichard Hughes <richard@hughsie.com>2013-08-13 08:39:46 +0100
commitc7c32250c4809f82b6c67198dbe848299d8df011 (patch)
tree6955422754bcf7d2856d3112653bf6d65b39cb8f
parent417dbd20a8997da1885651532caf8aeb4b0af446 (diff)
downloadcolord-c7c32250c4809f82b6c67198dbe848299d8df011.tar.gz
libcolord: Return values larger than 1.0 when comparing a large gamut space to a small one
-rw-r--r--lib/colord/cd-icc-utils.c67
1 files changed, 53 insertions, 14 deletions
diff --git a/lib/colord/cd-icc-utils.c b/lib/colord/cd-icc-utils.c
index 7108143..1b634e5 100644
--- a/lib/colord/cd-icc-utils.c
+++ b/lib/colord/cd-icc-utils.c
@@ -54,21 +54,13 @@ cd_icc_utils_get_coverage_sample_cb (const cmsFloat32Number in[],
}
/**
- * cd_icc_utils_get_coverage:
- * @icc: The profile to test
- * @icc_reference: The reference profile, e.g. sRGB
- * @coverage: The coverage of @icc on @icc_reference
- * @error: A #GError, or %NULL
- *
- * Gets the gamut coverage of two profiles.
- *
- * Return value: TRUE for success
+ * cd_icc_utils_get_coverage_calc:
**/
-gboolean
-cd_icc_utils_get_coverage (CdIcc *icc,
- CdIcc *icc_reference,
- gdouble *coverage,
- GError **error)
+static gboolean
+cd_icc_utils_get_coverage_calc (CdIcc *icc,
+ CdIcc *icc_reference,
+ gdouble *coverage,
+ GError **error)
{
const guint cube_size = 33;
cmsFloat32Number *data = NULL;
@@ -142,3 +134,50 @@ out:
cmsDeleteTransform (transform);
return ret;
}
+
+/**
+ * cd_icc_utils_get_coverage:
+ * @icc: The profile to test
+ * @icc_reference: The reference profile, e.g. sRGB
+ * @coverage: The coverage of @icc on @icc_reference
+ * @error: A #GError, or %NULL
+ *
+ * Gets the gamut coverage of two profiles where 0.5 would mean the gamut is
+ * half the size, and 2.0 would indicate the gamut is twice the size.
+ *
+ * Return value: TRUE for success
+ **/
+gboolean
+cd_icc_utils_get_coverage (CdIcc *icc,
+ CdIcc *icc_reference,
+ gdouble *coverage,
+ GError **error)
+{
+ gboolean ret;
+ gdouble coverage_tmp;
+
+ /* first see if icc has a smaller gamut volume to the reference */
+ ret = cd_icc_utils_get_coverage_calc (icc,
+ icc_reference,
+ &coverage_tmp,
+ error);
+ if (!ret)
+ goto out;
+
+ /* now try the other way around */
+ if (coverage_tmp >= 1.0f) {
+ ret = cd_icc_utils_get_coverage_calc (icc_reference,
+ icc,
+ &coverage_tmp,
+ error);
+ if (!ret)
+ goto out;
+ coverage_tmp = 1 / coverage_tmp;
+ }
+
+ /* success */
+ if (coverage != NULL)
+ *coverage = coverage_tmp;
+out:
+ return ret;
+}