summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2009-06-25 09:16:41 -0400
committerJeff Muizelaar <jmuizelaar@mozilla.com>2009-06-25 10:47:04 -0400
commitd2f6ba16c87084f954a19052732271dd8c627427 (patch)
tree55de436ce6f7b7f7786e199debe4bd084e1aea1b
parent4ff2fedd90de58b2a25fa27c05d913644e506c88 (diff)
Profiles with negative colorant tristiumlus values are bogus.
Discovered with profiles from https://bugzilla.mozilla.org/show_bug.cgi?id=498245
-rw-r--r--iccread.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/iccread.c b/iccread.c
index 7a5cbb4..e9a6eac 100644
--- a/iccread.c
+++ b/iccread.c
@@ -223,18 +223,37 @@ static struct tag_index read_tag_table(qcms_profile *profile, struct mem_source
qcms_bool qcms_profile_is_bogus(qcms_profile *profile)
{
float sum[3], target[3], tolerance[3];
+ float rX, rY, rZ, gX, gY, gZ, bX, bY, bZ;
+ bool negative;
unsigned i;
- // Sum the values
- sum[0] = s15Fixed16Number_to_float(profile->redColorant.X) +
- s15Fixed16Number_to_float(profile->greenColorant.X) +
- s15Fixed16Number_to_float(profile->blueColorant.X);
- sum[1] = s15Fixed16Number_to_float(profile->redColorant.Y) +
- s15Fixed16Number_to_float(profile->greenColorant.Y) +
- s15Fixed16Number_to_float(profile->blueColorant.Y);
- sum[2] = s15Fixed16Number_to_float(profile->redColorant.Z) +
- s15Fixed16Number_to_float(profile->greenColorant.Z) +
- s15Fixed16Number_to_float(profile->blueColorant.Z);
+ rX = s15Fixed16Number_to_float(profile->redColorant.X);
+ rY = s15Fixed16Number_to_float(profile->redColorant.Y);
+ rZ = s15Fixed16Number_to_float(profile->redColorant.Z);
+
+ gX = s15Fixed16Number_to_float(profile->greenColorant.X);
+ gY = s15Fixed16Number_to_float(profile->greenColorant.Y);
+ gZ = s15Fixed16Number_to_float(profile->greenColorant.Z);
+
+ bX = s15Fixed16Number_to_float(profile->blueColorant.X);
+ bY = s15Fixed16Number_to_float(profile->blueColorant.Y);
+ bZ = s15Fixed16Number_to_float(profile->blueColorant.Z);
+
+ // Check if any of the XYZ values are negative (see mozilla bug 498245)
+ // CIEXYZ tristimulus values cannot be negative according to the spec.
+ negative =
+ (rX < 0) || (rY < 0) || (rZ < 0) ||
+ (gX < 0) || (gY < 0) || (gZ < 0) ||
+ (bX < 0) || (bY < 0) || (bZ < 0);
+
+ if (negative)
+ return true;
+
+
+ // Sum the values; they should add up to something close to white
+ sum[0] = rX + gX + bX;
+ sum[1] = rY + gY + bY;
+ sum[2] = rZ + gZ + bZ;
// Build our target vector (see mozilla bug 460629)
target[0] = 0.96420;