Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 67cbd58

Browse files
committed
Fixed regression introduced in 0.9.2
1 parent 606b377 commit 67cbd58

File tree

12 files changed

+35
-19
lines changed

12 files changed

+35
-19
lines changed

ColorSharp.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ Global
3333
$0.VersionControlPolicy = $2
3434
$2.inheritsSet = Mono
3535
description = A .Net/Mono library to handle color spaces (and light spectrums!)
36-
version = 0.9.2
36+
version = 0.9.3
3737
EndGlobalSection
3838
EndGlobal

ColorSharp/ColorSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<SignAssembly>true</SignAssembly>
1212
<DelaySign>true</DelaySign>
1313
<AssemblyOriginatorKeyFile>colorsharp.pub</AssemblyOriginatorKeyFile>
14-
<ReleaseVersion>0.9.2</ReleaseVersion>
14+
<ReleaseVersion>0.9.3</ReleaseVersion>
1515
</PropertyGroup>
1616
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1717
<DebugSymbols>true</DebugSymbols>

ColorSharp/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
4747
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
4848

49-
[assembly: AssemblyVersion ("0.9.2.*")]
49+
[assembly: AssemblyVersion ("0.9.3.*")]
5050

5151
// The following attributes are used to specify the signing key for the assembly,
5252
// if desired. See the Mono documentation for more information about signing.

ColorSharp/src/ColorSpaces/AConvertibleColor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ AConvertibleColor InnerConvertTo (Type t, ConversionStrategy strategy = Conversi
122122
/**
123123
* <summary>Tells us if the object represents a valid color sample in current color space.</summary>
124124
*/
125-
public abstract bool IsInsideColorSpace ();
125+
public abstract bool IsInsideColorSpace (bool highPrecision = false);
126126

127127
/**
128128
* <summary>Converts the color sample to a CIE's 1931 XYZ color sample.</summary>

ColorSharp/src/ColorSpaces/CIEUVW.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public CIEUVW (double U, double V, double W, AConvertibleColor dataSource=null)
7676
/**
7777
* <inheritdoc />
7878
*/
79-
public override bool IsInsideColorSpace()
79+
public override bool IsInsideColorSpace(bool highPrecision = false)
8080
{
8181
// TODO : Improve ?
82-
return ToCIExyY ().IsInsideColorSpace ();
82+
return ToCIExyY ().IsInsideColorSpace (highPrecision);
8383
}
8484

8585
/**

ColorSharp/src/ColorSpaces/CIEXYZ.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public CIEXYZ (double X, double Y, double Z, AConvertibleColor dataSource=null)
8383
/**
8484
* <inheritdoc />
8585
*/
86-
public override bool IsInsideColorSpace()
86+
public override bool IsInsideColorSpace(bool highPrecision = false)
8787
{
88-
return ToCIExyY ().IsInsideColorSpace ();
88+
return ToCIExyY ().IsInsideColorSpace (highPrecision);
8989
}
9090

9191
/**

ColorSharp/src/ColorSpaces/CIExyY.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,17 @@ static void computeSharkfin(IList<double> mfX, IList<double> mfY, IList<double>
110110

111111
for (int i = 0; i < n; i++) {
112112
var XYZ = mfX [i] + mfY [i] + mfZ [i];
113-
Sharkfin [i] = new xyYPoint { x = mfX [i] / XYZ, y = mfY [i] / XYZ };
113+
114+
if (Math.Abs (XYZ) < double.Epsilon) {
115+
Sharkfin [i] = new xyYPoint { x = 0.0, y = 0.0 };
116+
} else {
117+
Sharkfin [i] = new xyYPoint { x = mfX [i] / XYZ, y = mfY [i] / XYZ };
118+
}
114119
}
115120

116121
// Used to speedup the convex hull algorithm
117122
SortedSharkfin = (xyYPoint[])Sharkfin.Clone();
123+
118124
Array.Sort (SortedSharkfin, new xyYPointComparer());
119125
}
120126

@@ -140,15 +146,23 @@ public CIExyY (double x, double y, double Y, AConvertibleColor dataSource=null)
140146
/**
141147
* <inheritdoc />
142148
*/
143-
public override bool IsInsideColorSpace()
149+
public override bool IsInsideColorSpace(bool highPrecision = false)
144150
{
145151
// Fast checks
146152
if (y > 1.0 - x || y < (x - 0.25) * 0.5 || y < 0.4 - x * 4 || y >= 0.85)
147153
return false;
148154

149-
xyYPoint[] points = new xyYPoint[SortedSharkfin5Nm.Length + 1];
150-
Array.Copy (SortedSharkfin5Nm, 0, points, 0, SortedSharkfin5Nm.Length);
151-
points[SortedSharkfin5Nm.Length] = new xyYPoint{x=x, y=y};
155+
xyYPoint[] points;
156+
157+
if (highPrecision) {
158+
points = new xyYPoint[SortedSharkfin1Nm.Length + 1];
159+
Array.Copy (SortedSharkfin1Nm, 0, points, 0, SortedSharkfin1Nm.Length);
160+
points [SortedSharkfin1Nm.Length] = new xyYPoint{ x = x, y = y };
161+
} else {
162+
points = new xyYPoint[SortedSharkfin5Nm.Length + 1];
163+
Array.Copy (SortedSharkfin5Nm, 0, points, 0, SortedSharkfin5Nm.Length);
164+
points [SortedSharkfin5Nm.Length] = new xyYPoint{ x = x, y = y };
165+
}
152166

153167
xyYPoint[] convexHull = findConvexHull (points);
154168

@@ -191,7 +205,7 @@ public override bool Equals(Object obj)
191205
if (xyYObj == this) {
192206
return true;
193207
}
194-
if (xyYObj == null || GetHashCode () != obj.GetHashCode ()) {
208+
if (xyYObj == null) {
195209
return false;
196210
}
197211

ColorSharp/src/ColorSpaces/SRGB.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public SRGB (double R, double G, double B, AConvertibleColor dataSource=null) :
8484
/**
8585
* <inheritdoc />
8686
*/
87-
public override bool IsInsideColorSpace()
87+
public override bool IsInsideColorSpace(bool highPrecision = false)
8888
{
8989
return (
9090
0.0 <= R && R <= 1.0 &&

ColorSharp/src/LightSpectrums/RegularLightSpectrum.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public override double GetNextAmplitudeSample (double waveLength)
173173
/**
174174
* <inheritdoc />
175175
*/
176-
public override bool IsInsideColorSpace()
176+
public override bool IsInsideColorSpace(bool highPrecision = false)
177177
{
178178
if (MinWaveLength <= double.Epsilon)
179179
return false;

ColorSharp/src/LightSpectrums/TabularLightSpectrum.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public override double GetNextAmplitudeSample (double waveLength)
156156
/**
157157
* <inheritdoc />
158158
*/
159-
public override bool IsInsideColorSpace()
159+
public override bool IsInsideColorSpace(bool highPrecision = false)
160160
{
161161
if (RawAmplitudes[0].Key <= double.Epsilon)
162162
return false;

0 commit comments

Comments
 (0)