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

Commit 66fdef2

Browse files
committed
Bugfix in sRGB->CIE's 1931 XYZ conversion
1 parent 6fdc11d commit 66fdef2

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

ColorSharp.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Global
3434
$0.VersionControlPolicy = $2
3535
$2.inheritsSet = Mono
3636
description = A .Net/Mono library to handle color spaces (and light spectrums!)
37-
version = 0.5.2
37+
version = 0.6.0
3838
EndGlobalSection
3939
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>false</DelaySign>
1313
<AssemblyOriginatorKeyFile>colorsharp.snk</AssemblyOriginatorKeyFile>
14-
<ReleaseVersion>0.5.2</ReleaseVersion>
14+
<ReleaseVersion>0.6.0</ReleaseVersion>
1515
</PropertyGroup>
1616
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1717
<DebugSymbols>true</DebugSymbols>

ColorSharp/ColorSharp.nuspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
<projectUrl>https://github.com/Litipk/ColorSharp</projectUrl>
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1212
<description>$description$</description>
13-
<releaseNotes>Bugfixes in RegularLightSpectrum</releaseNotes>
13+
<releaseNotes>
14+
- Improved documentation
15+
- Minor cleanups
16+
- Bugfix in sRGB -> CIE's 1931 XYZ conversion
17+
</releaseNotes>
1418
<copyright>Copyright 2014</copyright>
1519
<tags>Light Color Colour CIEXYZ CIExyY sRGB</tags>
1620
</metadata>

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.5.2.*")]
49+
[assembly: AssemblyVersion ("0.6.0.*")]
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/SRGB.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ public SRGB (double R, double G, double B, AConvertibleColor dataSource=null) :
7474
*/
7575
public CIEXYZ ToCIEXYZ (ConversionStrategy strategy=ConversionStrategy.Default)
7676
{
77-
// Linear transformation
78-
double X = R * 0.412424 + G * 0.357579 + B * 0.180464;
79-
double Y = R * 0.212656 + G * 0.715158 + B * 0.072186;
80-
double Z = R * 0.019332 + G * 0.119193 + B * 0.950444;
81-
8277
// Gamma correction
83-
X = X > 0.04045 ? Math.Pow((X+0.055)/1.055, 2.4) : X/12.92 ;
84-
Y = Y > 0.04045 ? Math.Pow((Y+0.055)/1.055, 2.4) : Y/12.92 ;
85-
Z = Z > 0.04045 ? Math.Pow((Z+0.055)/1.055, 2.4) : Z/12.92 ;
86-
87-
return new CIEXYZ(X, Y, Z, DataSource ?? this);
78+
double r = R > 0.04045 ? Math.Pow((R+0.055)/1.055, 2.4) : R/12.92 ;
79+
double g = G > 0.04045 ? Math.Pow((G+0.055)/1.055, 2.4) : G/12.92 ;
80+
double b = B > 0.04045 ? Math.Pow((B+0.055)/1.055, 2.4) : B/12.92 ;
81+
82+
return new CIEXYZ(
83+
// Linear transformation
84+
r * 0.412424 + g * 0.357579 + b * 0.180464,
85+
r * 0.212656 + g * 0.715158 + b * 0.072186,
86+
r * 0.019332 + g * 0.119193 + b * 0.950444,
87+
DataSource ?? this
88+
);
8889
}
8990

9091
#endregion

ColorSharpTests/ColorSharpTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>Litipk.ColorSharpTests</RootNamespace>
99
<AssemblyName>ColorSharpTests</AssemblyName>
10-
<ReleaseVersion>0.5.2</ReleaseVersion>
10+
<ReleaseVersion>0.6.0</ReleaseVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>

0 commit comments

Comments
 (0)