├── UI
├── ICCViewer
│ ├── Mac
│ │ └── MyApp.app
│ │ │ └── Contents
│ │ │ ├── MacOS
│ │ │ └── Launcher.exec
│ │ │ ├── Resources
│ │ │ └── Icon.icns
│ │ │ └── Info.plist
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── packages.config
├── ColorConverter
│ ├── Mac
│ │ └── MyApp.app
│ │ │ └── Contents
│ │ │ ├── MacOS
│ │ │ └── Launcher.exec
│ │ │ ├── Resources
│ │ │ └── Icon.icns
│ │ │ └── Info.plist
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── packages.config
├── ICCViewerLib
│ ├── Controls
│ │ ├── CurveControl.xeto
│ │ ├── LocalizedStringControl.xeto
│ │ ├── ProfileSequenceIdentifierControl.xeto.cs
│ │ ├── ProfileSequenceIdentifierControl.xeto
│ │ ├── LUTControl.xeto
│ │ ├── TextDescriptionControl.xeto.cs
│ │ ├── LocalizedStringControl.xeto.cs
│ │ ├── TextDescriptionControl.xeto
│ │ ├── ClutControl.xeto
│ │ ├── ProfileDescriptionControl.xeto.cs
│ │ └── ProfileDescriptionControl.xeto
│ ├── DetailsForm.xeto
│ ├── packages.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── DetailsForm.xeto.cs
└── ColorConverterLib
│ ├── packages.config
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── ColorControl.xeto
│ ├── MainForm.xeto
│ ├── MainForm.xeto.cs
│ └── ColorConverterLib.csproj
├── ColorManagerTests
├── Helper
│ ├── Compare.cs
│ ├── ArrayHelper.cs
│ └── ColorDifference.cs
├── ClassImplementations
│ ├── TestConversionData.cs
│ ├── TestConversionPath.cs
│ ├── TestChromaticAdaption.cs
│ ├── TestWhitepoint.cs
│ ├── TestColor.cs
│ └── TestColorspaceRGB.cs
├── Properties
│ └── AssemblyInfo.cs
├── ICC
│ ├── ICCProfileWriterTest.cs
│ └── ICCProfileReaderTest.cs
└── Color
│ ├── Comparison
│ ├── CMP_Colorspace.cs
│ ├── CMP_ChromaticAdaption.cs
│ ├── CMP_ColorspaceGray.cs
│ ├── CMP_Whitepoint.cs
│ ├── CMP_Color.cs
│ └── CMP_ConversionPath.cs
│ ├── Conversions
│ ├── Lab_Gray.cs
│ ├── RGB_HSL.cs
│ ├── RGB_HSV.cs
│ ├── XYZ_Luv.cs
│ ├── DEF_Bef.cs
│ ├── DEF_BCH.cs
│ ├── XYZ_Yxy.cs
│ ├── XYZ_RGB.cs
│ ├── Lab_LCHab.cs
│ ├── XYZ_LCH99c.cs
│ ├── XYZ_Lab.cs
│ ├── Luv_LCHuv.cs
│ ├── XYZ_LCH99d.cs
│ ├── Lab_LCH99.cs
│ ├── Lab_LCH99b.cs
│ └── XYZ_DEF.cs
│ └── ColorDifferences
│ ├── CD_DIN99.cs
│ ├── CD_CMC.cs
│ ├── CD_CIE94.cs
│ ├── CD_CIEDE2000.cs
│ └── CD_CIE76.cs
├── ColorManager
├── Properties
│ └── AssemblyInfo.cs
├── ICC
│ └── ICCValidator.cs
├── ColorDifference
│ ├── Base
│ │ ├── Enums.cs
│ │ └── ColorLabDifferenceCalculator.cs
│ ├── ColorDifference_CIE76.cs
│ └── ColorDifference_CIE94.cs
├── Base
│ ├── CAData.cs
│ └── ChromaticAdaption.cs
├── Colors
│ ├── ColorLCH99.cs
│ ├── ColorLCH99b.cs
│ ├── ColorLCH99c.cs
│ ├── ColorLCH99d.cs
│ └── Base
│ │ └── ColorLCH99Base.cs
├── Whitepoints
│ ├── WhitepointE.cs
│ ├── WhitepointA.cs
│ ├── WhitepointB.cs
│ ├── WhitepointC.cs
│ ├── WhitepointF2.cs
│ ├── WhitepointF7.cs
│ ├── WhitepointD50.cs
│ ├── WhitepointD55.cs
│ ├── WhitepointD65.cs
│ ├── WhitepointD75.cs
│ └── WhitepointF11.cs
├── ChromaticAdaption
│ └── XYZ
│ │ ├── CA_XYZ_Data.cs
│ │ └── CA_XYZ.cs
├── Helper
│ └── Delegates.cs
├── Conversions
│ ├── Gray.cs
│ ├── LCHab.cs
│ ├── RGB.cs
│ ├── LCHuv.cs
│ ├── DEF.cs
│ ├── Bef.cs
│ └── Yxy.cs
└── Colorspaces
│ ├── ColorspaceICC.cs
│ └── RGB
│ ├── Colorspace_CIERGB.cs
│ ├── Colorspace_NTSCRGB.cs
│ ├── Colorspace_BetaRGB.cs
│ ├── Colorspace_AdobeRGB.cs
│ ├── Colorspace_AppleRGB.cs
│ ├── Colorspace_BruceRGB.cs
│ ├── Colorspace_DonRGB4.cs
│ ├── Colorspace_ProPhotoRGB.cs
│ ├── Colorspace_BestRGB.cs
│ ├── Colorspace_PAL_SECAMRGB.cs
│ ├── Colorspace_SMPTE_C_RGB.cs
│ ├── Colorspace_EktaSpacePS5.cs
│ └── Colorspace_WideGamutRGB.cs
├── LICENSE
└── README.md
/UI/ICCViewer/Mac/MyApp.app/Contents/MacOS/Launcher.exec:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABildstein/NCM/HEAD/UI/ICCViewer/Mac/MyApp.app/Contents/MacOS/Launcher.exec
--------------------------------------------------------------------------------
/UI/ICCViewer/Mac/MyApp.app/Contents/Resources/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABildstein/NCM/HEAD/UI/ICCViewer/Mac/MyApp.app/Contents/Resources/Icon.icns
--------------------------------------------------------------------------------
/UI/ColorConverter/Mac/MyApp.app/Contents/MacOS/Launcher.exec:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABildstein/NCM/HEAD/UI/ColorConverter/Mac/MyApp.app/Contents/MacOS/Launcher.exec
--------------------------------------------------------------------------------
/UI/ColorConverter/Mac/MyApp.app/Contents/Resources/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABildstein/NCM/HEAD/UI/ColorConverter/Mac/MyApp.app/Contents/Resources/Icon.icns
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/CurveControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/LocalizedStringControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/DetailsForm.xeto:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ColorManagerTests/Helper/Compare.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManagerTests.Comparison
3 | {
4 | public abstract class Compare
5 | {
6 | public abstract void IsEqualSame();
7 | public abstract void IsUnEqualSame();
8 | public abstract void Equal();
9 | public abstract void Unequal();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/UI/ICCViewer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("ICCViewer")]
4 | [assembly: AssemblyDescription("ICC profile viewer UI for NCM")]
5 | [assembly: AssemblyProduct("ICCViewer")]
6 | [assembly: AssemblyCopyright("Copyright © Johannes Bildstein 2016")]
7 |
8 | [assembly: AssemblyVersion("1.0.*")]
9 |
--------------------------------------------------------------------------------
/UI/ColorConverter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("ColorConverter")]
4 | [assembly: AssemblyDescription("Color Converter UI for NCM")]
5 | [assembly: AssemblyProduct("ColorConverter")]
6 | [assembly: AssemblyCopyright("Copyright © Johannes Bildstein 2016")]
7 |
8 | [assembly: AssemblyVersion("1.0.*")]
9 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("ICCViewerLib")]
4 | [assembly: AssemblyDescription("Library for ICC profile viewer UI")]
5 | [assembly: AssemblyProduct("ICCViewerLib")]
6 | [assembly: AssemblyCopyright("Copyright © Johannes Bildstein 2016")]
7 |
8 | [assembly: AssemblyVersion("1.0.*")]
9 |
--------------------------------------------------------------------------------
/UI/ICCViewer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Eto;
3 | using Eto.Forms;
4 |
5 | namespace ICCViewer.Desktop
6 | {
7 | public class Program
8 | {
9 | [STAThread]
10 | public static void Main(string[] args)
11 | {
12 | new Application(Platform.Detect).Run(new MainForm());
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("ColorConverterLib")]
4 | [assembly: AssemblyDescription("Library for Color Converter UI")]
5 | [assembly: AssemblyProduct("ColorConverterLib")]
6 | [assembly: AssemblyCopyright("Copyright © 2016")]
7 |
8 | [assembly: AssemblyVersion("1.0.*")]
9 |
10 |
--------------------------------------------------------------------------------
/UI/ColorConverter/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Eto;
3 | using Eto.Forms;
4 |
5 | namespace ColorConverter.Desktop
6 | {
7 | public class Program
8 | {
9 | [STAThread]
10 | public static void Main(string[] args)
11 | {
12 | new Application(Platform.Detect).Run(new MainForm());
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestConversionData.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.Conversion;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | public class TestConversionData : ConversionData
7 | {
8 | public TestConversionData(Color inColor, Color outColor)
9 | : base(inColor, outColor)
10 | { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/DetailsForm.xeto.cs:
--------------------------------------------------------------------------------
1 | using Eto.Forms;
2 | using Eto.Serialization.Xaml;
3 |
4 | namespace ICCViewer
5 | {
6 | public class DetailsForm : Form
7 | {
8 | Scrollable ScrollContainer { get; set; }
9 |
10 | public DetailsForm(Control ctrl)
11 | {
12 | XamlReader.Load(this);
13 | ScrollContainer.Content = ctrl;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ColorManager/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyTitle("ColorManager")]
5 | [assembly: AssemblyDescription("Color conversion library")]
6 | [assembly: AssemblyProduct("ColorManager")]
7 | [assembly: AssemblyCopyright("Copyright © Johannes Bildstein 2015")]
8 |
9 | [assembly: AssemblyVersion("0.1.0.0")]
10 | [assembly: AssemblyFileVersion("0.1.0.0")]
11 |
12 | [assembly: ComVisible(false)]
13 |
--------------------------------------------------------------------------------
/ColorManagerTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyTitle("ColorManagerTests")]
5 | [assembly: AssemblyDescription("Color conversion library unit tests")]
6 | [assembly: AssemblyProduct("ColorManagerTests")]
7 | [assembly: AssemblyCopyright("Copyright © Johannes Bildstein 2015")]
8 |
9 | [assembly: AssemblyVersion("0.1.0.0")]
10 | [assembly: AssemblyFileVersion("0.1.0.0")]
11 |
12 | [assembly: ComVisible(false)]
13 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/ColorControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ColorManagerTests/ICC/ICCProfileWriterTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using ColorManager.ICC;
4 |
5 | namespace ColorManagerTests.ICC
6 | {
7 | [TestClass]
8 | public class ICCProfileWriterTest
9 | {
10 | [TestMethod]
11 | public void WriteProfileArray()
12 | {
13 | Assert.Inconclusive("Not implemented");
14 | }
15 |
16 | [TestMethod]
17 | public void WriteProfileStream()
18 | {
19 | Assert.Inconclusive("Not implemented");
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/UI/ICCViewer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/UI/ColorConverter/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ColorManager/ICC/ICCValidator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.ICC
4 | {
5 | ///
6 | /// Provides methods to check validity of an ICC profile
7 | ///
8 | public static class ICCValidator
9 | {
10 | //LTODO: implement ICCValidator (partially see Annex G)
11 |
12 | ///
13 | /// Validates an ICC profile
14 | ///
15 | /// The profile to validate
16 | /// True if valid; false otherwise
17 | public static bool Validate(ICCProfile profile)
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestConversionPath.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ColorManager.Conversion;
3 |
4 | namespace ColorManagerTests
5 | {
6 | public sealed class TestConversionPath : ConversionPath
7 | {
8 | public override IConversionCommand[] Commands
9 | {
10 | get { throw new NotImplementedException(); }
11 | }
12 | public override Type From
13 | {
14 | get { return ftp; }
15 | }
16 | public override Type To
17 | {
18 | get { return ttp; }
19 | }
20 |
21 | private Type ftp, ttp;
22 |
23 | public TestConversionPath(Type From, Type To)
24 | {
25 | ftp = From;
26 | ttp = To;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/ProfileSequenceIdentifierControl.xeto.cs:
--------------------------------------------------------------------------------
1 | using Eto.Forms;
2 | using Eto.Serialization.Xaml;
3 | using ColorManager.ICC;
4 |
5 | namespace ICCViewer.Controls
6 | {
7 | public class ProfileSequenceIdentifierControl : Panel
8 | {
9 | Label ProfileIDLabel { get; set; }
10 | LocalizedStringControl EntryLabeDescriptionPanell { get; set; }
11 |
12 | public ProfileSequenceIdentifierControl()
13 | {
14 | XamlReader.Load(this);
15 | }
16 |
17 | public ProfileSequenceIdentifierControl(ProfileSequenceIdentifier data)
18 | : this()
19 | {
20 | ProfileIDLabel.Text = data.ID.ToString();
21 | EntryLabeDescriptionPanell = new LocalizedStringControl(data.Description);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestChromaticAdaption.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ColorManager;
3 | using ColorManager.Conversion;
4 |
5 | namespace ColorManagerTests
6 | {
7 | public sealed class TestChromaticAdaption : ChromaticAdaption
8 | {
9 | public override Type ColorType
10 | {
11 | get { return tp; }
12 | }
13 | public override ConversionDelegate Method
14 | {
15 | get { throw new NotImplementedException(); }
16 | }
17 |
18 | private Type tp;
19 |
20 | public TestChromaticAdaption(Type tp)
21 | {
22 | this.tp = tp;
23 | }
24 |
25 | public override CustomData GetCAData(ConversionData data)
26 | {
27 | throw new NotImplementedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/ProfileSequenceIdentifierControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/LUTControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ColorManager/ColorDifference/Base/Enums.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager.ColorDifference
3 | {
4 | ///
5 | /// Method to calculate the CIE 94 color difference
6 | ///
7 | public enum CIE94DifferenceMethod
8 | {
9 | ///
10 | /// SL=1; K1=0.045; K2=0.015;
11 | ///
12 | GraphicArts,
13 | ///
14 | /// SL=2; K1=0.048; K2=0.014;
15 | ///
16 | Textiles,
17 | }
18 |
19 | ///
20 | /// Method to calculate the CMC color difference
21 | ///
22 | public enum CMCDifferenceMethod
23 | {
24 | ///
25 | /// luma:chromaticity = 2:1
26 | ///
27 | Acceptability = 2,
28 | ///
29 | /// luma:chromaticity = 1:1
30 | ///
31 | Perceptibility = 1,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ColorManagerTests/Helper/ArrayHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace ColorManagerTests
4 | {
5 | public static class ArrayHelper
6 | {
7 | public static T[] Concat(params T[][] arrs)
8 | {
9 | var result = new T[arrs.Sum(t => t.Length)];
10 | int offset = 0;
11 | for (int i = 0; i < arrs.Length; i++)
12 | {
13 | arrs[i].CopyTo(result, offset);
14 | offset += arrs[i].Length;
15 | }
16 | return result;
17 | }
18 |
19 | public static T[] Fill(T value, int length)
20 | {
21 | var result = new T[length];
22 | for (int i = 0; i < length; i++)
23 | {
24 | result[i] = value;
25 | }
26 | return result;
27 | }
28 |
29 | public static string Fill(char value, int length)
30 | {
31 | return "".PadRight(length, value);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/TextDescriptionControl.xeto.cs:
--------------------------------------------------------------------------------
1 | using ColorManager.ICC;
2 | using Eto.Forms;
3 | using Eto.Serialization.Xaml;
4 |
5 | namespace ICCViewer.Controls
6 | {
7 | public class TextDescriptionControl : Panel
8 | {
9 | TextArea AsciiTextArea { get; set; }
10 | TextArea UnicodeTextArea { get; set; }
11 | TextArea ScriptCodeTextArea { get; set; }
12 |
13 | Label LanguageCodeLabel { get; set; }
14 | Label ScriptCodeLabel { get; set; }
15 |
16 | public TextDescriptionControl()
17 | {
18 | XamlReader.Load(this);
19 | }
20 |
21 | public TextDescriptionControl(TextDescriptionTagDataEntry data)
22 | : this()
23 | {
24 | AsciiTextArea.Text = data.ASCII;
25 | UnicodeTextArea.Text = data.Unicode;
26 | ScriptCodeTextArea.Text = data.ScriptCode;
27 |
28 | LanguageCodeLabel.Text = data.UnicodeLanguageCode.ToString();
29 | ScriptCodeLabel.Text = data.ScriptCodeCode.ToString();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/LocalizedStringControl.xeto.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using ColorManager.ICC;
3 | using Eto.Forms;
4 | using Eto.Serialization.Xaml;
5 |
6 | namespace ICCViewer.Controls
7 | {
8 | public class LocalizedStringControl : Panel
9 | {
10 | private TabControl LocaleTabs { get; set; }
11 |
12 | public LocalizedStringControl()
13 | {
14 | XamlReader.Load(this);
15 | }
16 |
17 | public LocalizedStringControl(IEnumerable data)
18 | : this()
19 | {
20 | foreach (var lstring in data)
21 | {
22 | var tab = new TabPage();
23 | var scroll = new Scrollable();
24 | var text = new TextArea();
25 | text.ReadOnly = true;
26 | text.Text = lstring.Text;
27 | tab.Text = lstring.Culture;
28 | tab.Content = scroll;
29 | scroll.Content = text;
30 | LocaleTabs.Pages.Add(tab);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ColorManager/Base/CAData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.Conversion
4 | {
5 | ///
6 | /// Container for custom conversion data (abstract class)
7 | ///
8 | public abstract unsafe class CustomData : IDisposable
9 | {
10 | ///
11 | /// Pointer to the data
12 | ///
13 | public abstract void* DataPointer { get; }
14 |
15 | ///
16 | /// Finalizer of the class
17 | ///
18 | ~CustomData()
19 | {
20 | Dispose(false);
21 | }
22 |
23 | ///
24 | /// Releases all allocated resources
25 | ///
26 | public void Dispose()
27 | {
28 | Dispose(true);
29 | GC.SuppressFinalize(this);
30 | }
31 |
32 | ///
33 | /// Releases all allocated resources
34 | ///
35 | /// True if called by user, false if called by finalizer
36 | protected abstract void Dispose(bool managed);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/MainForm.xeto:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Johannes Bildstein
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/ColorManagerTests/ICC/ICCProfileReaderTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using ColorManager.ICC;
4 |
5 | namespace ColorManagerTests.ICC
6 | {
7 | [TestClass]
8 | public class ICCProfileReaderTest
9 | {
10 | [TestMethod]
11 | public void ReadArray()
12 | {
13 | Assert.Inconclusive("Not implemented");
14 | }
15 |
16 | [TestMethod]
17 | public void ReadFile()
18 | {
19 | Assert.Inconclusive("Not implemented");
20 | }
21 |
22 | [TestMethod]
23 | public void ReadStream()
24 | {
25 | Assert.Inconclusive("Not implemented");
26 | }
27 |
28 | [TestMethod]
29 | public void ReadHeaderArray()
30 | {
31 | Assert.Inconclusive("Not implemented");
32 | }
33 |
34 | [TestMethod]
35 | public void ReadHeaderFile()
36 | {
37 | Assert.Inconclusive("Not implemented");
38 | }
39 |
40 | [TestMethod]
41 | public void ReadHeaderStream()
42 | {
43 | Assert.Inconclusive("Not implemented");
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/TextDescriptionControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestWhitepoint.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 |
3 | namespace ColorManagerTests
4 | {
5 | public sealed class TestWhitepoint : Whitepoint
6 | {
7 | public override string Name
8 | {
9 | get { return "Test"; }
10 | }
11 | public override double Cx
12 | {
13 | get { return _Cx; }
14 | }
15 | public override double Cy
16 | {
17 | get { return _Cy; }
18 | }
19 | public override double X
20 | {
21 | get { return _X; }
22 | }
23 | public override double Y
24 | {
25 | get { return _Y; }
26 | }
27 | public override double Z
28 | {
29 | get { return _Z; }
30 | }
31 |
32 | private double _X, _Y, _Z, _Cx, _Cy;
33 |
34 | public TestWhitepoint()
35 | {
36 | _X = _Y = _Z = _Cx = _Cy = 0.5;
37 | }
38 |
39 | public TestWhitepoint(double X, double Y, double Z, double Cx, double Cy)
40 | {
41 | _X = X;
42 | _Y = Y;
43 | _Z = Z;
44 | _Cx = Cx;
45 | _Cy = Cy;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/ClutControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ColorManagerTests/Helper/ColorDifference.cs:
--------------------------------------------------------------------------------
1 | using ColorManager.ColorDifference;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.ColorDifferences
5 | {
6 | public abstract class ColorDifference
7 | {
8 | public abstract double[] DeltaEOutput { get; }
9 | public abstract double[] DeltaHOutput { get; }
10 | public abstract double[] DeltaCOutput { get; }
11 |
12 | protected const double Margin = 0.00005;
13 |
14 | protected void DeltaE(ColorDifferenceCalculator cdc, int idx)
15 | {
16 | var result = cdc.DeltaE();
17 | Assert.AreEqual(DeltaEOutput[idx], result, Margin);
18 | }
19 |
20 | protected void DeltaH(ColorDifferenceCalculator cdc, int idx)
21 | {
22 | var result = cdc.DeltaH();
23 | Assert.AreEqual(DeltaHOutput[idx], result, Margin);
24 | }
25 |
26 | protected void DeltaC(ColorDifferenceCalculator cdc, int idx)
27 | {
28 | var result = cdc.DeltaC();
29 | Assert.AreEqual(DeltaCOutput[idx], result, Margin);
30 | }
31 |
32 | public abstract void DeltaE();
33 | public abstract void DeltaH();
34 | public abstract void DeltaC();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ColorManager/ColorDifference/ColorDifference_CIE76.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.ColorDifference
4 | {
5 | ///
6 | /// Provides methods to calculate the difference between two colors by the CIE76 formula
7 | ///
8 | public unsafe sealed class ColorDifference_CIE76 : ColorLabDifferenceCalculator
9 | {
10 | ///
11 | /// Creates a new instance of the class
12 | ///
13 | /// First color to compare
14 | /// Second color to compare
15 | public ColorDifference_CIE76(ColorLab Color1, ColorLab Color2)
16 | : base(Color1, Color2)
17 | { }
18 |
19 | ///
20 | /// Calculate the difference between two colors
21 | ///
22 | /// The difference between Color1 and Color2
23 | public override double DeltaE()
24 | {
25 | Vars[0] = Col2Values[0] - Col1Values[0];
26 | Vars[1] = Col2Values[1] - Col1Values[1];
27 | Vars[2] = Col2Values[2] - Col1Values[2];
28 |
29 | return Math.Sqrt(Vars[0] * Vars[0] + Vars[1] * Vars[1] + Vars[2] * Vars[2]);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ColorManager/Colors/ColorLCH99.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager
3 | {
4 | ///
5 | /// Stores information and values of the LCH99 color model
6 | ///
7 | public sealed class ColorLCH99 : ColorLCH99Base
8 | {
9 | ///
10 | /// The name of this model
11 | ///
12 | public override string Name
13 | {
14 | get { return ModelName; }
15 | }
16 | ///
17 | /// The name of this model
18 | ///
19 | public static string ModelName
20 | {
21 | get { return "LCH99"; }
22 | }
23 |
24 | ///
25 | /// Creates a new instance of the class
26 | ///
27 | public ColorLCH99()
28 | : base()
29 | { }
30 |
31 | ///
32 | /// Creates a new instance of the class
33 | ///
34 | /// Value for the Lightness channel
35 | /// Value for the Chroma channel
36 | /// Value for the Hue channel
37 | public ColorLCH99(double L, double C, double H)
38 | : base(L, C, H)
39 | { }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Colors/ColorLCH99b.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager
3 | {
4 | ///
5 | /// Stores information and values of the LCH99b color model
6 | ///
7 | public sealed class ColorLCH99b : ColorLCH99Base
8 | {
9 | ///
10 | /// The name of this model
11 | ///
12 | public override string Name
13 | {
14 | get { return ModelName; }
15 | }
16 | ///
17 | /// The name of this model
18 | ///
19 | public static string ModelName
20 | {
21 | get { return "LCH99b"; }
22 | }
23 |
24 | ///
25 | /// Creates a new instance of the class
26 | ///
27 | public ColorLCH99b()
28 | : base()
29 | { }
30 |
31 | ///
32 | /// Creates a new instance of the class
33 | ///
34 | /// Value for the Lightness channel
35 | /// Value for the Chroma channel
36 | /// Value for the Hue channel
37 | public ColorLCH99b(double L, double C, double H)
38 | : base(L, C, H)
39 | { }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Colors/ColorLCH99c.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager
3 | {
4 | ///
5 | /// Stores information and values of the LCH99c color model
6 | ///
7 | public sealed class ColorLCH99c : ColorLCH99Base
8 | {
9 | ///
10 | /// The name of this model
11 | ///
12 | public override string Name
13 | {
14 | get { return ModelName; }
15 | }
16 | ///
17 | /// The name of this model
18 | ///
19 | public static string ModelName
20 | {
21 | get { return "LCH99c"; }
22 | }
23 |
24 | ///
25 | /// Creates a new instance of the class
26 | ///
27 | public ColorLCH99c()
28 | : base()
29 | { }
30 |
31 | ///
32 | /// Creates a new instance of the class
33 | ///
34 | /// Value for the Lightness channel
35 | /// Value for the Chroma channel
36 | /// Value for the Hue channel
37 | public ColorLCH99c(double L, double C, double H)
38 | : base(L, C, H)
39 | { }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Colors/ColorLCH99d.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager
3 | {
4 | ///
5 | /// Stores information and values of the LCH99d color model
6 | ///
7 | public sealed class ColorLCH99d : ColorLCH99Base
8 | {
9 | ///
10 | /// The name of this model
11 | ///
12 | public override string Name
13 | {
14 | get { return ModelName; }
15 | }
16 | ///
17 | /// The name of this model
18 | ///
19 | public static string ModelName
20 | {
21 | get { return "LCH99d"; }
22 | }
23 |
24 | ///
25 | /// Creates a new instance of the class
26 | ///
27 | public ColorLCH99d()
28 | : base()
29 | { }
30 |
31 | ///
32 | /// Creates a new instance of the class
33 | ///
34 | /// Value for the Lightness channel
35 | /// Value for the Chroma channel
36 | /// Value for the Hue channel
37 | public ColorLCH99d(double L, double C, double H)
38 | : base(L, C, H)
39 | { }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointE.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an E whitepoint
5 | ///
6 | public sealed class WhitepointE : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "E"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 1.0;
36 | private const double y = 1.0;
37 | private const double z = 1.0;
38 | private const double cx = 1.0 / 3d;
39 | private const double cy = 1.0 / 3d;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointA.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an A whitepoint
5 | ///
6 | public sealed class WhitepointA : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "A"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 1.0985;
36 | private const double y = 1.0;
37 | private const double z = 0.35585;
38 | private const double cx = 0.44757;
39 | private const double cy = 0.40745;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointB.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an B whitepoint
5 | ///
6 | public sealed class WhitepointB : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "B"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.99072;
36 | private const double y = 1.0;
37 | private const double z = 0.85223;
38 | private const double cx = 0.34842;
39 | private const double cy = 0.35161;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointC.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an C whitepoint
5 | ///
6 | public sealed class WhitepointC : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "C"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.98074;
36 | private const double y = 1.0;
37 | private const double z = 1.18232;
38 | private const double cx = 0.31006;
39 | private const double cy = 0.31616;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointF2.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an F2 whitepoint
5 | ///
6 | public sealed class WhitepointF2 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "F2"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.99186;
36 | private const double y = 1.0;
37 | private const double z = 0.67393;
38 | private const double cx = 0.37208;
39 | private const double cy = 0.37529;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointF7.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an F7 whitepoint
5 | ///
6 | public sealed class WhitepointF7 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "F7"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.95041;
36 | private const double y = 1.0;
37 | private const double z = 1.08747;
38 | private const double cx = 0.31292;
39 | private const double cy = 0.32933;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointD50.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an D50 whitepoint
5 | ///
6 | public sealed class WhitepointD50 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "D50"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.96422;
36 | private const double y = 1.0;
37 | private const double z = 0.82521;
38 | private const double cx = 0.34567;
39 | private const double cy = 0.3585;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointD55.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an D55 whitepoint
5 | ///
6 | public sealed class WhitepointD55 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "D55"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.95682;
36 | private const double y = 1.0;
37 | private const double z = 0.92149;
38 | private const double cx = 0.33242;
39 | private const double cy = 0.34743;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointD65.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an D65 whitepoint
5 | ///
6 | public sealed class WhitepointD65 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "D65"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.95047;
36 | private const double y = 1.0;
37 | private const double z = 1.08883;
38 | private const double cx = 0.31271;
39 | private const double cy = 0.32902;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointD75.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an D75 whitepoint
5 | ///
6 | public sealed class WhitepointD75 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "D75"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 0.94972;
36 | private const double y = 1.0;
37 | private const double z = 1.22638;
38 | private const double cx = 0.29902;
39 | private const double cy = 0.31485;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManager/Whitepoints/WhitepointF11.cs:
--------------------------------------------------------------------------------
1 | namespace ColorManager
2 | {
3 | ///
4 | /// Stores information and values of an F11 whitepoint
5 | ///
6 | public sealed class WhitepointF11 : Whitepoint
7 | {
8 | ///
9 | /// The name of this whitepoint
10 | ///
11 | public override string Name { get { return "F11"; } }
12 |
13 | ///
14 | /// X value
15 | ///
16 | public override double X { get { return x; } }
17 | ///
18 | /// Y value
19 | ///
20 | public override double Y { get { return y; } }
21 | ///
22 | /// Z value
23 | ///
24 | public override double Z { get { return z; } }
25 |
26 | ///
27 | /// x chromaticity value
28 | ///
29 | public override double Cx { get { return cx; } }
30 | ///
31 | /// y chromaticity value
32 | ///
33 | public override double Cy { get { return cy; } }
34 |
35 | private const double x = 1.00962;
36 | private const double y = 1.0;
37 | private const double z = 0.6435;
38 | private const double cx = 0.38052;
39 | private const double cy = 0.37713;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/UI/ICCViewer/Mac/MyApp.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MonoBundleExecutable
6 | ICCViewer.exe
7 | CFBundleName
8 | MacAppTemplate
9 | CFBundleIdentifier
10 | com.bildstein.iccviewer
11 | CFBundleShortVersionString
12 | 1.0
13 | CFBundleVersion
14 | 1
15 | NSHumanReadableCopyright
16 | Copyright © Johannes Bildstein
17 | CFBundleIconFile
18 | Icon.icns
19 | CFBundleExecutable
20 | Launcher.exec
21 | BuildMachineOSBuild
22 | 12A269
23 | CFBundleDevelopmentRegion
24 | en
25 | CFBundleInfoDictionaryVersion
26 | 6.0
27 | CFBundlePackageType
28 | APPL
29 | CFBundleResourceSpecification
30 | ResourceRules.plist
31 | CFBundleSignature
32 | ????
33 | LSMinimumSystemVersion
34 | 10.5
35 | NSPrincipalClass
36 | NSApplication
37 |
38 |
39 |
--------------------------------------------------------------------------------
/UI/ColorConverter/Mac/MyApp.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MonoBundleExecutable
6 | ColorConverter.exe
7 | CFBundleName
8 | Color Converter
9 | CFBundleIdentifier
10 | com.bildstein.colorconverter
11 | CFBundleShortVersionString
12 | 1.0
13 | CFBundleVersion
14 | 1
15 | NSHumanReadableCopyright
16 | Copyright © Johannes Bildstein
17 | CFBundleIconFile
18 | Icon.icns
19 | CFBundleExecutable
20 | Launcher.exec
21 | BuildMachineOSBuild
22 | 12A269
23 | CFBundleDevelopmentRegion
24 | en
25 | CFBundleInfoDictionaryVersion
26 | 6.0
27 | CFBundlePackageType
28 | APPL
29 | CFBundleResourceSpecification
30 | ResourceRules.plist
31 | CFBundleSignature
32 | ????
33 | LSMinimumSystemVersion
34 | 10.5
35 | NSPrincipalClass
36 | NSApplication
37 |
38 |
39 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestColor.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 |
3 | namespace ColorManagerTests
4 | {
5 | public sealed class TestColor : Color
6 | {
7 | public override string Name
8 | {
9 | get { return "Test"; }
10 | }
11 | public override int ChannelCount
12 | {
13 | get { return 3; }
14 | }
15 | public override string[] ChannelFullNames
16 | {
17 | get { return new string[] { "1", "2", "3" }; }
18 | }
19 | public override string[] ChannelShortNames
20 | {
21 | get { return new string[] { "1", "2", "3" }; }
22 | }
23 | public override double[] MinValues
24 | {
25 | get { return new double[] { 0, 0, 0 }; }
26 | }
27 | public override double[] MaxValues
28 | {
29 | get { return new double[] { 1, 1, 1 }; }
30 | }
31 |
32 | public TestColor()
33 | : base(Colorspace.Default, 0, 0, 0)
34 | { }
35 |
36 | public TestColor(Colorspace space)
37 | : base(space, 0, 0, 0)
38 | { }
39 |
40 | public TestColor(double val1, double val2, double val3)
41 | : base(Colorspace.Default, val1, val2, val3)
42 | { }
43 |
44 | public TestColor(double val1, double val2, double val3, Colorspace space)
45 | : base(space, val1, val2, val3)
46 | { }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ColorManager/ChromaticAdaption/XYZ/CA_XYZ_Data.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace ColorManager.Conversion
5 | {
6 | ///
7 | /// Container for XZY chromatic adaption conversion data
8 | ///
9 | public sealed unsafe class CA_XYZ_Data : CustomData
10 | {
11 | ///
12 | /// Pointer to the data
13 | ///
14 | public override void* DataPointer
15 | {
16 | get { return DataHandle.AddrOfPinnedObject().ToPointer(); }
17 | }
18 | private GCHandle DataHandle;
19 |
20 | ///
21 | /// Creates a new instance of the class
22 | ///
23 | /// The matrix for the chromatic adaption
24 | public CA_XYZ_Data(double[] matrix)
25 | {
26 | if (matrix == null) throw new ArgumentNullException(nameof(matrix));
27 | if (matrix.Length != 9) throw new ArgumentException("Matrix has to have a length of nine");
28 |
29 | DataHandle = GCHandle.Alloc(matrix, GCHandleType.Pinned);
30 | }
31 |
32 | ///
33 | /// Releases all allocated resources
34 | ///
35 | /// True if called by user, false if called by finalizer
36 | protected override void Dispose(bool managed)
37 | {
38 | if (DataHandle.IsAllocated) DataHandle.Free();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_Colorspace.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Comparison
5 | {
6 | [TestClass]
7 | public class CMP_Colorspace : Compare
8 | {
9 | [TestMethod]
10 | public override void IsEqualSame()
11 | {
12 | var cs1 = new Colorspace();
13 | var cs2 = new Colorspace();
14 |
15 | bool cmp1 = cs1 == cs2;
16 | bool cmp2 = cs1.Equals(cs2);
17 |
18 | Assert.IsTrue(cmp1 == cmp2);
19 | }
20 |
21 | [TestMethod]
22 | public override void IsUnEqualSame()
23 | {
24 | var cs1 = new Colorspace();
25 | var cs2 = new Colorspace();
26 |
27 | bool cmp1 = !(cs1 == cs2);
28 | bool cmp2 = cs1 != cs2;
29 |
30 | Assert.IsTrue(cmp1 == cmp2);
31 | }
32 |
33 | [TestMethod]
34 | public override void Equal()
35 | {
36 | var cs1 = new Colorspace(Whitepoint.A);
37 | var cs2 = new Colorspace(Whitepoint.A);
38 | var cs3 = new Colorspace(Whitepoint.B);
39 |
40 | Assert.IsTrue(cs1 == cs2);
41 | Assert.IsFalse(cs1 == cs3);
42 | }
43 |
44 | [TestMethod]
45 | public override void Unequal()
46 | {
47 | var cs1 = new Colorspace(Whitepoint.A);
48 | var cs2 = new Colorspace(Whitepoint.A);
49 | var cs3 = new Colorspace(Whitepoint.B);
50 |
51 | Assert.IsFalse(cs1 != cs2);
52 | Assert.IsTrue(cs1 != cs3);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_ChromaticAdaption.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Comparison
5 | {
6 | [TestClass]
7 | public class CMP_ChromaticAdaption : Compare
8 | {
9 | [TestMethod]
10 | public override void IsEqualSame()
11 | {
12 | var ca1 = new TestChromaticAdaption(typeof(ColorXYZ));
13 | var ca2 = new TestChromaticAdaption(typeof(ColorXYZ));
14 |
15 | bool cmp1 = ca1 == ca2;
16 | bool cmp2 = ca1.Equals(ca2);
17 |
18 | Assert.IsTrue(cmp1 == cmp2);
19 | }
20 |
21 | [TestMethod]
22 | public override void IsUnEqualSame()
23 | {
24 | var ca1 = new TestChromaticAdaption(typeof(ColorXYZ));
25 | var ca2 = new TestChromaticAdaption(typeof(ColorXYZ));
26 |
27 | bool cmp1 = !(ca1 == ca2);
28 | bool cmp2 = ca1 != ca2;
29 |
30 | Assert.IsTrue(cmp1 == cmp2);
31 | }
32 |
33 | [TestMethod]
34 | public override void Equal()
35 | {
36 | var ca1 = new TestChromaticAdaption(typeof(ColorXYZ));
37 | var ca2 = new TestChromaticAdaption(typeof(ColorXYZ));
38 | var ca3 = new TestChromaticAdaption(typeof(ColorLab));
39 |
40 | Assert.IsTrue(ca1 == ca2);
41 | Assert.IsFalse(ca1 == ca3);
42 | }
43 |
44 | [TestMethod]
45 | public override void Unequal()
46 | {
47 | var ca1 = new TestChromaticAdaption(typeof(ColorXYZ));
48 | var ca2 = new TestChromaticAdaption(typeof(ColorXYZ));
49 | var ca3 = new TestChromaticAdaption(typeof(ColorLab));
50 |
51 | Assert.IsFalse(ca1 != ca2);
52 | Assert.IsTrue(ca1 != ca3);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_ColorspaceGray.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Comparison
5 | {
6 | [TestClass]
7 | public class CMP_ColorspaceGray : Compare
8 | {
9 | [TestMethod]
10 | public override void IsEqualSame()
11 | {
12 | var cs1 = new ColorspaceGray();
13 | var cs2 = new ColorspaceGray();
14 |
15 | bool cmp1 = cs1 == cs2;
16 | bool cmp2 = cs1.Equals(cs2);
17 |
18 | Assert.IsTrue(cmp1 == cmp2);
19 | }
20 |
21 | [TestMethod]
22 | public override void IsUnEqualSame()
23 | {
24 | var cs1 = new ColorspaceGray();
25 | var cs2 = new ColorspaceGray();
26 |
27 | bool cmp1 = !(cs1 == cs2);
28 | bool cmp2 = cs1 != cs2;
29 |
30 | Assert.IsTrue(cmp1 == cmp2);
31 | }
32 |
33 | [TestMethod]
34 | public override void Equal()
35 | {
36 | var cs1 = new ColorspaceGray(Whitepoint.A, 2.2);
37 | var cs2 = new ColorspaceGray(Whitepoint.A, 2.2);
38 |
39 | var cs3 = new ColorspaceGray(Whitepoint.A, 2.0);
40 | var cs4 = new ColorspaceGray(Whitepoint.B, 2.0);
41 |
42 | Assert.IsTrue(cs1 == cs2);
43 |
44 | Assert.IsFalse(cs1 == cs3);
45 | Assert.IsFalse(cs1 == cs4);
46 | }
47 |
48 | [TestMethod]
49 | public override void Unequal()
50 | {
51 | var cs1 = new ColorspaceGray(Whitepoint.A, 2.2);
52 | var cs2 = new ColorspaceGray(Whitepoint.A, 2.2);
53 |
54 | var cs3 = new ColorspaceGray(Whitepoint.A, 2.0);
55 | var cs4 = new ColorspaceGray(Whitepoint.B, 2.0);
56 |
57 | Assert.IsFalse(cs1 != cs2);
58 |
59 | Assert.IsTrue(cs1 != cs3);
60 | Assert.IsTrue(cs1 != cs4);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/MainForm.xeto.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using ColorManager;
4 | using Eto.Forms;
5 | using Eto.Serialization.Xaml;
6 | using CConverter = ColorManager.ColorConverter;
7 |
8 | namespace ColorConverter
9 | {
10 | public class MainForm : Form
11 | {
12 | ColorControl InColorCtrl { get; set; }
13 | ColorControl OutColorCtrl { get; set; }
14 | Button ConvertButton { get; set; }
15 |
16 | public MainForm()
17 | {
18 | XamlReader.Load(this);
19 | ConvertButton.Click += ConvertButton_Click;
20 |
21 | //Eto Bug, custom control is not assigned:
22 | if (InColorCtrl == null)
23 | {
24 | InColorCtrl = Children
25 | .FirstOrDefault(t => t is ColorControl && t.ID == nameof(InColorCtrl))
26 | as ColorControl;
27 | }
28 |
29 | //Eto Bug, custom control is not assigned:
30 | if (OutColorCtrl == null)
31 | {
32 | OutColorCtrl = Children
33 | .FirstOrDefault(t => t is ColorControl && t.ID == nameof(OutColorCtrl))
34 | as ColorControl;
35 | }
36 | }
37 |
38 | private void ConvertButton_Click(object sender, EventArgs e)
39 | {
40 | try
41 | {
42 | ConvertButton.Enabled = false;
43 | Color colIn = InColorCtrl.GetColorInstance();
44 | Color colOut = OutColorCtrl.GetColorInstance();
45 | using (CConverter conv = new CConverter(colIn, colOut))
46 | {
47 | conv.Convert();
48 | }
49 | OutColorCtrl.SetValues(colOut);
50 | }
51 | catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); }
52 | finally { ConvertButton.Enabled = true; }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_Whitepoint.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 |
3 | namespace ColorManagerTests.Comparison
4 | {
5 | [TestClass]
6 | public class CMP_Whitepoint : Compare
7 | {
8 | [TestMethod]
9 | public override void IsEqualSame()
10 | {
11 | var wp1 = new TestWhitepoint();
12 | var wp2 = new TestWhitepoint();
13 |
14 | bool cmp1 = wp1 == wp2;
15 | bool cmp2 = wp1.Equals(wp2);
16 |
17 | Assert.IsTrue(cmp1 == cmp2);
18 | }
19 |
20 | [TestMethod]
21 | public override void IsUnEqualSame()
22 | {
23 | var wp1 = new TestWhitepoint();
24 | var wp2 = new TestWhitepoint();
25 |
26 | bool cmp1 = !(wp1 == wp2);
27 | bool cmp2 = wp1 != wp2;
28 |
29 | Assert.IsTrue(cmp1 == cmp2);
30 | }
31 |
32 | [TestMethod]
33 | public override void Equal()
34 | {
35 | var wp1 = new TestWhitepoint(0.5, 0.5, 0.5, 0.5, 0.5);
36 | var wp2 = new TestWhitepoint(0.5, 0.5, 0.5, 0.5, 0.5);
37 |
38 | var wp3 = new TestWhitepoint(0.7, 0.7, 0.7, 0.7, 0.7);
39 | var wp4 = new TestWhitepoint(0.7, 0.7, 0.7, 0.2, 0.2);
40 |
41 | Assert.IsTrue(wp1 == wp2);
42 |
43 | Assert.IsFalse(wp1 == wp3);
44 | Assert.IsFalse(wp1 == wp4);
45 | }
46 |
47 | [TestMethod]
48 | public override void Unequal()
49 | {
50 | var wp1 = new TestWhitepoint(0.5, 0.5, 0.5, 0.5, 0.5);
51 | var wp2 = new TestWhitepoint(0.5, 0.5, 0.5, 0.5, 0.5);
52 |
53 | var wp3 = new TestWhitepoint(0.7, 0.7, 0.7, 0.7, 0.7);
54 | var wp4 = new TestWhitepoint(0.7, 0.7, 0.7, 0.2, 0.2);
55 |
56 | Assert.IsFalse(wp1 != wp2);
57 |
58 | Assert.IsTrue(wp1 != wp3);
59 | Assert.IsTrue(wp1 != wp4);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/ProfileDescriptionControl.xeto.cs:
--------------------------------------------------------------------------------
1 | using ColorManager.ICC;
2 | using Eto.Forms;
3 | using Eto.Serialization.Xaml;
4 |
5 | namespace ICCViewer.Controls
6 | {
7 | public class ProfileDescriptionControl : Panel
8 | {
9 | private Label DeviceManufacturerLabel { get; set; }
10 | private Label DeviceModelLabel { get; set; }
11 | private Label TechnologyInformationLabel { get; set; }
12 | private Label OpacityLabel { get; set; }
13 | private Label ReflectivityLabel { get; set; }
14 | private Label PolarityLabel { get; set; }
15 | private Label ChromaLabel { get; set; }
16 | private Label VendorDataLabel { get; set; }
17 | private LocalizedStringControl DeviceManufacturerInfoPanel { get; set; }
18 | private LocalizedStringControl DeviceModelInfoPanel { get; set; }
19 |
20 | public ProfileDescriptionControl()
21 | {
22 | XamlReader.Load(this);
23 | }
24 |
25 | public ProfileDescriptionControl(ProfileDescription data)
26 | : this()
27 | {
28 | DeviceManufacturerLabel.Text = data.DeviceManufacturer.ToString();
29 | DeviceModelLabel.Text = data.DeviceModel.ToString();
30 | TechnologyInformationLabel.Text = data.TechnologyInformation.ToString();
31 | OpacityLabel.Text = data.DeviceAttributes.Opacity.ToString();
32 | ReflectivityLabel.Text = data.DeviceAttributes.Reflectivity.ToString();
33 | PolarityLabel.Text = data.DeviceAttributes.Polarity.ToString();
34 | ChromaLabel.Text = data.DeviceAttributes.Chroma.ToString();
35 | VendorDataLabel.Text = Conversion.FromBytesShort(data.DeviceAttributes.VendorData, true);
36 |
37 | DeviceManufacturerInfoPanel = new LocalizedStringControl(data.DeviceManufacturerInfo);
38 | DeviceModelInfoPanel = new LocalizedStringControl(data.DeviceModelInfo);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ColorManagerTests/ClassImplementations/TestColorspaceRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ColorManager;
3 |
4 | namespace ColorManagerTests
5 | {
6 | public sealed class TestColorspaceRGB : ColorspaceRGB
7 | {
8 | public override string Name
9 | {
10 | get { return "Test"; }
11 | }
12 | public override double Gamma
13 | {
14 | get { return _Gamma; }
15 | }
16 | public override double[] Cr
17 | {
18 | get { return _Cr; }
19 | }
20 | public override double[] Cg
21 | {
22 | get { return _Cg; }
23 | }
24 | public override double[] Cb
25 | {
26 | get { return _Cb; }
27 | }
28 |
29 | public override double[] CM
30 | {
31 | get { throw new NotImplementedException(); }
32 | }
33 | public override double[] ICM
34 | {
35 | get { throw new NotImplementedException(); }
36 | }
37 |
38 | private double[] _Cr, _Cg, _Cb;
39 | private double _Gamma;
40 |
41 | public TestColorspaceRGB()
42 | : base(Whitepoint.Default)
43 | {
44 | _Cr = new double[] { 0.5, 0.5 };
45 | _Cg = new double[] { 0.5, 0.5 };
46 | _Cb = new double[] { 0.5, 0.5 };
47 | _Gamma = 2.2;
48 | }
49 |
50 | public TestColorspaceRGB(Whitepoint wp, double[] Cr, double[] Cg, double[] Cb, double Gamma)
51 | : base(wp)
52 | {
53 | _Cr = Cr;
54 | _Cg = Cg;
55 | _Cb = Cb;
56 | _Gamma = Gamma;
57 | }
58 |
59 | public override unsafe void ToLinear(double* inVal, double* outVal)
60 | {
61 | throw new NotImplementedException();
62 | }
63 |
64 | public override unsafe void ToNonLinear(double* inVal, double* outVal)
65 | {
66 | throw new NotImplementedException();
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_Color.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Comparison
5 | {
6 | [TestClass]
7 | public class CMP_Color : Compare
8 | {
9 | [TestMethod]
10 | public override void IsEqualSame()
11 | {
12 | var col1 = new TestColor();
13 | var col2 = new TestColor();
14 |
15 | bool cmp1 = col1 == col2;
16 | bool cmp2 = col1.Equals(col2);
17 |
18 | Assert.IsTrue(cmp1 == cmp2);
19 | }
20 |
21 | [TestMethod]
22 | public override void IsUnEqualSame()
23 | {
24 | var col1 = new TestColor();
25 | var col2 = new TestColor();
26 |
27 | bool cmp1 = !(col1 == col2);
28 | bool cmp2 = col1 != col2;
29 |
30 | Assert.IsTrue(cmp1 == cmp2);
31 | }
32 |
33 | [TestMethod]
34 | public override void Equal()
35 | {
36 | var col1 = new TestColor(0.5, 0.5, 0.5, new Colorspace(Whitepoint.A));
37 | var col2 = new TestColor(0.5, 0.5, 0.5, new Colorspace(Whitepoint.A));
38 |
39 | var col3 = new TestColor(0.7, 0.7, 0.7, new Colorspace(Whitepoint.A));
40 | var col4 = new TestColor(0.7, 0.7, 0.7, new Colorspace(Whitepoint.B));
41 |
42 | Assert.IsTrue(col1 == col2);
43 |
44 | Assert.IsFalse(col1 == col3);
45 | Assert.IsFalse(col1 == col4);
46 | }
47 |
48 | [TestMethod]
49 | public override void Unequal()
50 | {
51 | var col1 = new TestColor(0.5, 0.5, 0.5, new Colorspace(Whitepoint.A));
52 | var col2 = new TestColor(0.5, 0.5, 0.5, new Colorspace(Whitepoint.A));
53 |
54 | var col3 = new TestColor(0.7, 0.7, 0.7, new Colorspace(Whitepoint.A));
55 | var col4 = new TestColor(0.7, 0.7, 0.7, new Colorspace(Whitepoint.B));
56 |
57 | Assert.IsFalse(col1 != col2);
58 |
59 | Assert.IsTrue(col1 != col3);
60 | Assert.IsTrue(col1 != col4);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ColorManager/ColorDifference/Base/ColorLabDifferenceCalculator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.ColorDifference
4 | {
5 | ///
6 | /// Provides methods to calculate the difference between two Lab colors (abstract class)
7 | ///
8 | public unsafe abstract class ColorLabDifferenceCalculator : ColorDifferenceCalculator
9 | {
10 | ///
11 | /// Creates a new instance of the class
12 | ///
13 | /// First color to compare
14 | /// Second color to compare
15 | protected ColorLabDifferenceCalculator(ColorLab Color1, ColorLab Color2)
16 | : base(Color1, Color2)
17 | { }
18 |
19 | ///
20 | /// Calculate the hue difference between two colors
21 | ///
22 | /// The hue difference between Color1 and Color2
23 | public override double DeltaH()
24 | {
25 | Vars[1] = Math.Sqrt(Col1Values[1] * Col1Values[1] + Col1Values[2] * Col1Values[2]); //C1
26 | Vars[2] = Math.Sqrt(Col2Values[1] * Col2Values[1] + Col2Values[2] * Col2Values[2]); //C2
27 |
28 | Vars[3] = Col1Values[1] - Col2Values[1];
29 | Vars[4] = Col1Values[2] - Col2Values[2];
30 | Vars[5] = Vars[1] - Vars[2];
31 |
32 | Vars[0] = Vars[3] * Vars[3] + Vars[4] * Vars[4] - Vars[5] * Vars[5];
33 |
34 | if (Vars[0] < 0) return 0;
35 | else return Math.Sqrt(Vars[0]);
36 | }
37 |
38 | ///
39 | /// Calculate the chroma difference between two colors
40 | ///
41 | /// The chroma difference between Color1 and Color2
42 | public override double DeltaC()
43 | {
44 | return Math.Sqrt(Col1Values[1] * Col1Values[1] + Col1Values[2] * Col1Values[2]) //C1
45 | - Math.Sqrt(Col2Values[1] * Col2Values[1] + Col2Values[2] * Col2Values[2]); //C1
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NCM
2 | A .Net color conversion/managment library
3 |
4 | ## Status
5 |
6 | - [x] Standard color conversion
7 | - [x] Reading ICC profiles
8 | - [x] Writing ICC profiles
9 | - [x] XML comments documentation (not for ICC yet)
10 | - [ ] ICC color conversion (partially implemented)
11 | - [ ] Documentation (code and usage)
12 |
13 | ## Basic Usage
14 |
15 | ```csharp
16 | var col1 = new ColorRGB(0.35, 0.17, 0.63, ColorspaceRGB.AdobeRGB);
17 | var col2 = new ColorXYZ(Whitepoint.D50);
18 |
19 | using (ColorConverter conv = new ColorConverter(col1, col2))
20 | {
21 | conv.Convert();
22 |
23 | Console.WriteLine(col2.X);
24 | Console.WriteLine(col2.Y);
25 | Console.WriteLine(col2.Z);
26 | }
27 | ```
28 | If you want to change the input color, it's best to use it like this:
29 |
30 | ```csharp
31 | var col1 = new ColorRGB(0.35, 0.17, 0.63, ColorspaceRGB.AdobeRGB);
32 | var col2 = new ColorXYZ(Whitepoint.D50);
33 |
34 | using (ColorConverter conv = new ColorConverter(col1, col2))
35 | {
36 | conv.Convert();
37 | Console.WriteLine("First conversion:");
38 | Console.WriteLine(col2.X);
39 | Console.WriteLine(col2.Y);
40 | Console.WriteLine(col2.Z);
41 |
42 | Console.WriteLine("Changing values...");
43 | col1[0] = 0.53;
44 | col1[1] = 0.72;
45 | col1[2] = 0.24;
46 | conv.Convert();
47 |
48 | Console.WriteLine("Second conversion:");
49 | Console.WriteLine(col2.X);
50 | Console.WriteLine(col2.Y);
51 | Console.WriteLine(col2.Z);
52 | }
53 | ```
54 |
55 | In general, keep in mind that creating a ColorConverter is expensive while the Convert method is cheap.
56 |
57 | ## Using the Source Code
58 |
59 | You need a C# coding environment with C#6 support. e.g. Visual Studio 2015 (any version is fine).
60 | The building process is like any other C# project and has no external dependencies.
61 |
62 | ## Contributions
63 |
64 | First off, thank you for any contribution!
65 |
66 | If you found a bug, please report it and I will try to fix it as soon as possible.
67 |
68 | I accept pull requests for bugfixes or new features but please first
69 | - check formatting and style
70 | - run the unit tests and see if they pass
71 | - add unit test(s) for the fix/feature (if possible)
72 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Comparison/CMP_ConversionPath.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Comparison
5 | {
6 | [TestClass]
7 | public class CMP_ConversionPath : Compare
8 | {
9 | [TestMethod]
10 | public override void IsEqualSame()
11 | {
12 | var cp1 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
13 | var cp2 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
14 |
15 | bool cmp1 = cp1 == cp2;
16 | bool cmp2 = cp1.Equals(cp2);
17 |
18 | Assert.IsTrue(cmp1 == cmp2);
19 | }
20 |
21 | [TestMethod]
22 | public override void IsUnEqualSame()
23 | {
24 | var cp1 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
25 | var cp2 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
26 |
27 | bool cmp1 = !(cp1 == cp2);
28 | bool cmp2 = cp1 != cp2;
29 |
30 | Assert.IsTrue(cmp1 == cmp2);
31 | }
32 |
33 | [TestMethod]
34 | public override void Equal()
35 | {
36 | var cp1 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
37 | var cp2 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
38 |
39 | var cp3 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorRGB));
40 | var cp4 = new TestConversionPath(typeof(ColorRGB), typeof(ColorXYZ));
41 |
42 | Assert.IsTrue(cp1 == cp2);
43 |
44 | Assert.IsFalse(cp1 == cp3);
45 | Assert.IsFalse(cp1 == cp4);
46 | }
47 |
48 | [TestMethod]
49 | public override void Unequal()
50 | {
51 | var cp1 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
52 | var cp2 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorLab));
53 |
54 | var cp3 = new TestConversionPath(typeof(ColorXYZ), typeof(ColorRGB));
55 | var cp4 = new TestConversionPath(typeof(ColorRGB), typeof(ColorXYZ));
56 |
57 | Assert.IsFalse(cp1 != cp2);
58 |
59 | Assert.IsTrue(cp1 != cp3);
60 | Assert.IsTrue(cp1 != cp4);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ColorManager/ChromaticAdaption/XYZ/CA_XYZ.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ColorManager.Conversion;
3 |
4 | namespace ColorManager
5 | {
6 | ///
7 | /// Represents an XYZ color chromatic adaption
8 | ///
9 | public unsafe sealed class CA_XYZ : ChromaticAdaption
10 | {
11 | ///
12 | /// The type of color this chromatic adaption is performed on (always typeof())
13 | ///
14 | public override Type ColorType { get { return typeof(ColorXYZ); } }
15 | ///
16 | /// The method to execute to do the chromatic adaption
17 | ///
18 | public override ConversionDelegate Method { get { return CAMethod; } }
19 |
20 | ///
21 | /// Gets the conversion data necessary for the chromatic adaption
22 | ///
23 | /// The data that is used to perform the chromatic adaption
24 | /// The conversion data necessary for the chromatic adaption
25 | public override CustomData GetCAData(ConversionData data)
26 | {
27 | var matrix = DefaultMethod.CalculateMatrix(data.InWP, data.OutWP);
28 | return new CA_XYZ_Data(matrix);
29 | }
30 |
31 | ///
32 | /// The default XYZ chromatic adaption method
33 | ///
34 | public static CA_XYZ_Method DefaultMethod
35 | {
36 | get { return _DefaultMethod; }
37 | set { if (value != null) _DefaultMethod = value; }
38 | }
39 | private static CA_XYZ_Method _DefaultMethod = new CA_XYZ_Bradford();
40 |
41 | ///
42 | /// The method that does the chromatic adaption
43 | ///
44 | /// The pointer to the input color values
45 | /// The pointer to the output color values
46 | /// The data that is used to perform the chromatic adaption
47 | public static void CAMethod(double* inColor, double* outColor, ConversionData data)
48 | {
49 | UMath.MultiplyMatrix_3x3_3x1((double*)data.CAData, inColor, outColor);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UI/ICCViewerLib/Controls/ProfileDescriptionControl.xeto:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/Lab_Gray.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class Lab_Gray : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 14.96419735484, -98.880598020684, -111.354721216184 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.421720084738 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.149641973548 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 1.531501900001, 0.0, 0.0 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 100.0, 0.0, 0.0 }; }
40 | }
41 |
42 | public Lab_Gray() : base(new ColorLab(Whitepoint.D65),
43 | new ColorGray(new ColorspaceGray(2.2)))
44 | { }
45 |
46 | [TestMethod]
47 | public void Lab_Gray_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void Lab_Gray_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void Lab_Gray_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void Gray_Lab_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void Gray_Lab_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void Gray_Lab_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManager/Helper/Delegates.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager.Conversion
3 | {
4 | ///
5 | /// A delegate for color conversions
6 | ///
7 | /// The pointer to the input color values
8 | /// The pointer to the output color values
9 | /// The data that is used to perform the conversion
10 | public unsafe delegate void ConversionDelegate(double* inColor, double* outColor, ConversionData data);
11 | ///
12 | /// A delegate for color conversions with additional data
13 | ///
14 | /// The pointer to the input color values
15 | /// The pointer to the output color values
16 | /// The data that is used to perform the conversion
17 | /// Additional data specific to this conversion
18 | public unsafe delegate void ConversionExDelegate(double* inColor, double* outColor, ConversionData data, double** additional);
19 | ///
20 | /// A delegate to transform values
21 | ///
22 | /// The pointer to the input values
23 | /// The pointer to the output values
24 | public unsafe delegate void TransformToDelegate(double* inValues, double* outValues);
25 | ///
26 | /// A delegate to transform values directly
27 | ///
28 | /// The pointer to the values to transform
29 | public unsafe delegate void TransformDelegate(double* values);
30 | ///
31 | /// A delegate to check one or more conditions according to some conversion data
32 | ///
33 | /// The data that will be used to perform a conversion
34 | /// The result of the condition
35 | public delegate bool ConditionDelegate(ConversionData data);
36 | ///
37 | /// A delegate to write IL code according to some conversion data
38 | ///
39 | /// The data that will be used to perform a conversion
40 | /// The IL writer with which the conversion code will be written
41 | public delegate void ILWriterDelegate(ConversionData data, ILWriter writer);
42 | }
43 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/Gray.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager.Conversion
3 | {
4 | ///
5 | /// Stores data about a conversion from to
6 | ///
7 | public sealed unsafe class Path_Lab_Gray : ConversionPath
8 | {
9 | ///
10 | /// An array of commands that convert from to
11 | ///
12 | public override IConversionCommand[] Commands
13 | {
14 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
15 | }
16 |
17 | ///
18 | /// The conversion method
19 | ///
20 | /// The pointer to the input color values
21 | /// The pointer to the output color values
22 | /// The data that is used to perform the conversion
23 | public static void Convert(double* inColor, double* outColor, ConversionData data)
24 | {
25 | outColor[0] = inColor[0] * 0.01;
26 | data.OutTransform(outColor, outColor);//Apply gamma
27 | }
28 | }
29 |
30 | ///
31 | /// Stores data about a conversion from to
32 | ///
33 | public sealed unsafe class Path_Gray_Lab : ConversionPath
34 | {
35 | ///
36 | /// An array of commands that convert from to
37 | ///
38 | public override IConversionCommand[] Commands
39 | {
40 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
41 | }
42 |
43 | ///
44 | /// The conversion method
45 | ///
46 | /// The pointer to the input color values
47 | /// The pointer to the output color values
48 | /// The data that is used to perform the conversion
49 | public static void Convert(double* inColor, double* outColor, ConversionData data)
50 | {
51 | data.InTransform(inColor, outColor);//Linearize gamma
52 | outColor[0] *= 100;
53 | outColor[1] = outColor[2] = 0;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/RGB_HSL.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class RGB_HSL : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.149641973548, 0.306116474469, 0.28165740938 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 170.621194528715, 0.343327702649, 0.227879224009 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 0.0, 0.0, 1.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 163.66544874742, 0.046609673694, 0.43789408225 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.417483981964, 0.458304182536, 0.44719118823 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.0, 1.0, 1.0 }; }
40 | }
41 |
42 | public RGB_HSL() : base(new ColorRGB(ColorspaceRGB.AdobeRGB),
43 | new ColorHSL(ColorspaceRGB.AdobeRGB))
44 | { }
45 |
46 | [TestMethod]
47 | public void RGB_HSL_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void RGB_HSL_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void RGB_HSL_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void HSL_RGB_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void HSL_RGB_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void HSL_RGB_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/RGB_HSV.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class RGB_HSV : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.454626246521, 0.046609673694, 0.43789408225 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 302.460512447522, 0.897476940562, 0.454626246521 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 0.0, 0.0, 1.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 163.66544874742, 0.046609673694, 0.43789408225 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.417483981964, 0.43789408225, 0.432337585097 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.0, 0.0, 0.0 }; }
40 | }
41 |
42 | public RGB_HSV() : base(new ColorRGB(ColorspaceRGB.AdobeRGB),
43 | new ColorHSV(ColorspaceRGB.AdobeRGB))
44 | { }
45 |
46 | [TestMethod]
47 | public void RGB_HSV_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void RGB_HSV_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void RGB_HSV_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void HSV_RGB_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void HSV_RGB_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void HSV_RGB_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_Luv.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_Luv : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.357404035985, 0.826589720196, 0.574532881996 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 92.864927879689, -119.648021449045, 54.849204651089 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 100.0, 16.492438258486, 6.952279872078 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 35.740403598519, 166.560757300146, 38.011769817915 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.201904590134, 0.088739191709, 0.0 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.0, 1.0, 0.0 }; }
40 | }
41 |
42 | public XYZ_Luv() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorLuv(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_Luv_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_Luv_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_Luv_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void Luv_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void Luv_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void Luv_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/DEF_Bef.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class DEF_Bef : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.149641973548, 0.306116474469, 0.28165740938 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.442075686334, 0.692452636352, 0.637124859129 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.732050807569, 0.57735026919, 0.57735026919 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.299283947097, -0.387767051062, -0.43668518124 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.24294461123, -0.116052453596, -0.13069286468 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 0.0, 2.0, 2.0 }; }
40 | }
41 |
42 | public DEF_Bef() : base(new ColorDEF(Whitepoint.D65),
43 | new ColorBef(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void DEF_Bef_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void DEF_Bef_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void DEF_Bef_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void Bef_DEF_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void Bef_DEF_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void Bef_DEF_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/DEF_BCH.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class DEF_BCH : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.149641973548, 0.306116474469, 0.28165740938 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.442075686334, 1.225475546729, 42.617122556746 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.732050807569, 0.955316618125, 45.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.224462960323, 0.459174711704, 101.396667376811 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.201212767596, -0.019658047086, 0.097522325126 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 0.106105802502, 1.496242479906, 0.0 }; }
40 | }
41 |
42 | public DEF_BCH() : base(new ColorDEF(Whitepoint.D65),
43 | new ColorBCH(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void DEF_BCH_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void DEF_BCH_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void DEF_BCH_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void BCH_DEF_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void BCH_DEF_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void BCH_DEF_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_Yxy.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_Yxy : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.315549002432, 0.387697047967, 0.849990960839 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.387697047967, 0.203155732286, 0.24960585227 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.31271, 0.32902 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.0, 0.333333333333, 0.333333333333 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.315549002432, -57.274505536665, 178.495390027992 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { -0.101251427749, 0.315549002432, -0.212529747501 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.0, 1.0, -1.996078431373 }; }
40 | }
41 |
42 | public XYZ_Yxy() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorYxy(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_Yxy_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_Yxy_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_Yxy_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void Yxy_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void Yxy_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void Yxy_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_RGB.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_RGB : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.315549002432, 0.387697047967, 0.849990960839 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.398403724731, 0.70028206455, 0.914440290514 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.057881256182, 0.97615153079, 0.958246449718 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.315549002432, 0.387697047967, 0.849990960839 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.200358302997, 0.154258363041, 0.704183153813 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 0.9504701, 1.0000001, 1.08883 }; }
40 | }
41 |
42 | public XYZ_RGB() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorRGB(ColorspaceRGB.AdobeRGB))
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_RGB_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_RGB_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_RGB_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void RGB_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void RGB_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void RGB_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/Lab_LCHab.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class Lab_LCHab : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 61.421368052914, 86.216007474678, 2.074585824308 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 61.421368052914, 86.240963881534, 1.378422430189 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 181.019335983756, -135.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 100.0, 179.605122421383, 45.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 61.421368052914, 214.216007474678, 183.634709399023 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 61.421368052914, -213.785113523192, -13.580246472989 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 100.0, 255.0, 0.0 }; }
40 | }
41 |
42 | public Lab_LCHab() : base(new ColorLab(Whitepoint.D65),
43 | new ColorLCHab(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void Lab_LCHab_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void Lab_LCHab_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void Lab_LCHab_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCHab_Lab_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCHab_Lab_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCHab_Lab_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_LCH99c.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_LCH99c : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.780120709413, 0.071643347909, 0.228429964082 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.915561931257, 0.341074281923, 71.548572202843 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.173139727391, 1.994348507092, 43.228530259966 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 78.012070941279, 5.0150343536, 82.23478706937 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 75.236752313075, 0.498781569253, 3.891179933373 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 100.000062571082, 302.698238337743, 0.0 }; }
40 | }
41 |
42 | public XYZ_LCH99c() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorLCH99c())
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_LCH99c_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_LCH99c_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_LCH99c_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCH99c_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCH99c_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCH99c_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_Lab.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_Lab : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.780120709413, 0.071643347909, 0.228429964082 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 32.178130833248, 260.477854161322, -35.773805753782 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 100.0, 8.538533672582, 5.593863452017 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 78.012070941279, -109.730946283313, -69.750359159196 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.196187885134, 0.532325034854, 1.696039503892 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { -0.031246842521, 0.0, 0.512605628496 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.87426512028, 1.0, 0.052946672514 }; }
40 | }
41 |
42 | public XYZ_Lab() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorLab(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_Lab_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_Lab_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_Lab_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void Lab_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void Lab_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void Lab_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/Luv_LCHuv.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class Luv_LCHuv : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 42.929035354373, -106.832587218649, -16.522765140293 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 42.929035354373, 108.102744922187, -171.208272031884 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 181.019335983756, -135.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 100.0, 179.605122421383, 45.0 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 61.421368052914, 214.216007474678, 183.634709399023 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 61.421368052914, -213.785113523192, -13.580246472989 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 100.0, 255.0, 0.0 }; }
40 | }
41 |
42 | public Luv_LCHuv() : base(new ColorLuv(Whitepoint.D65),
43 | new ColorLCHuv(Whitepoint.D65))
44 | { }
45 |
46 | [TestMethod]
47 | public void Luv_LCHuv_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void Luv_LCHuv_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void Luv_LCHuv_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCHuv_Luv_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCHuv_Luv_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCHuv_Luv_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_LCH99d.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_LCH99d : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.069197953501, 0.580555973635, 0.666333085492 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.081006570027, 1.162587975856, 14.786332383143 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 16.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.16869321214, 1.834498566302, 10.304322509353 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 6.919795350134, 40.638918154472, 239.879910777267 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 5.973662036485, 0.208319931305, -79.951775874195 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 99.999440645771, 287.05675082776, 207.651107668896 }; }
40 | }
41 |
42 | public XYZ_LCH99d() : base(new ColorXYZ(Whitepoint.D65),
43 | new ColorLCH99d())
44 | { }
45 |
46 | [TestMethod]
47 | public void XYZ_LCH99d_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void XYZ_LCH99d_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void XYZ_LCH99d_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCH99d_XYZ_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCH99d_XYZ_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCH99d_XYZ_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/Lab_LCH99.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class Lab_LCH99 : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 78.012070941279, -109.730946283313, -69.750359159196 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 84.741693247528, 42.369190027464, -168.328058316328 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 47.92536893765, -158.792933361646 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 100.001259481476, 47.771314144926, 21.207066638354 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 78.012070941279, 5.0150343536, 82.23478706937 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 69.280896658431, -1.464319302896, 7.86448656332 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 99.998050791985, 477.128962659218, 136.814528454417 }; }
40 | }
41 |
42 | public Lab_LCH99() : base(new ColorLab(Whitepoint.D65),
43 | new ColorLCH99())
44 | { }
45 |
46 | [TestMethod]
47 | public void Lab_LCH99_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void Lab_LCH99_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void Lab_LCH99_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCH99_Lab_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCH99_Lab_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCH99_Lab_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/Lab_LCH99b.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class Lab_LCH99b : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 78.012070941279, -109.730946283313, -69.750359159196 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 80.662889217191, 54.585606039678, -148.64610147749 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 61.26742286972, -138.050491824795 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 99.999998198541, 61.099646056654, 41.949508175205 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 78.012070941279, 5.0150343536, 82.23478706937 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 75.105521270677, 0.196448426161, 3.715940393499 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 100.000002114323, 276.85893992631, -21.496390511705 }; }
40 | }
41 |
42 | public Lab_LCH99b() : base(new ColorLab(Whitepoint.D65),
43 | new ColorLCH99b())
44 | { }
45 |
46 | [TestMethod]
47 | public void Lab_LCH99b_Random()
48 | {
49 | T_U_Random();
50 | }
51 |
52 | [TestMethod]
53 | public void Lab_LCH99b_Min()
54 | {
55 | T_U_Min();
56 | }
57 |
58 | [TestMethod]
59 | public void Lab_LCH99b_Max()
60 | {
61 | T_U_Max();
62 | }
63 |
64 | [TestMethod]
65 | public void LCH99b_Lab_Random()
66 | {
67 | U_T_Random();
68 | }
69 |
70 | [TestMethod]
71 | public void LCH99b_Lab_Min()
72 | {
73 | U_T_Min();
74 | }
75 |
76 | [TestMethod]
77 | public void LCH99b_Lab_Max()
78 | {
79 | U_T_Max();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/LCHab.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.Conversion
4 | {
5 | ///
6 | /// Stores data about a conversion from to
7 | ///
8 | public sealed unsafe class Path_Lab_LCHab : ConversionPath
9 | {
10 | ///
11 | /// An array of commands that convert from to
12 | ///
13 | public override IConversionCommand[] Commands
14 | {
15 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
16 | }
17 |
18 | ///
19 | /// The conversion method
20 | ///
21 | /// The pointer to the input color values
22 | /// The pointer to the output color values
23 | /// The data that is used to perform the conversion
24 | public static void Convert(double* inColor, double* outColor, ConversionData data)
25 | {
26 | outColor[0] = inColor[0];
27 | outColor[1] = Math.Sqrt(inColor[1] * inColor[1] + inColor[2] * inColor[2]);
28 | outColor[2] = Math.Atan2(inColor[2], inColor[1]) * Const.Pi180_1;
29 | }
30 | }
31 |
32 | ///
33 | /// Stores data about a conversion from to
34 | ///
35 | public sealed unsafe class Path_LCHab_Lab : ConversionPath
36 | {
37 | ///
38 | /// An array of commands that convert from to
39 | ///
40 | public override IConversionCommand[] Commands
41 | {
42 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
43 | }
44 |
45 | ///
46 | /// The conversion method
47 | ///
48 | /// The pointer to the input color values
49 | /// The pointer to the output color values
50 | /// The data that is used to perform the conversion
51 | public static void Convert(double* inColor, double* outColor, ConversionData data)
52 | {
53 | outColor[0] = inColor[0];
54 | outColor[1] = inColor[1] * Math.Cos(inColor[2] * Const.Pi180);
55 | outColor[2] = inColor[1] * Math.Sin(inColor[2] * Const.Pi180);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/RGB.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager.Conversion
3 | {
4 | ///
5 | /// Stores data about a conversion from to
6 | ///
7 | public sealed unsafe class Path_XYZ_RGB : ConversionPath
8 | {
9 | ///
10 | /// An array of commands that convert from to
11 | ///
12 | public override IConversionCommand[] Commands
13 | {
14 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
15 | }
16 |
17 | ///
18 | /// The conversion method
19 | ///
20 | /// The pointer to the input color values
21 | /// The pointer to the output color values
22 | /// The data that is used to perform the conversion
23 | public static void Convert(double* inColor, double* outColor, ConversionData data)
24 | {
25 | UMath.MultiplyMatrix_3x3_3x1((double*)data.OutSpaceData, inColor, outColor);
26 | if (outColor[0] < 0) outColor[0] = 0;
27 | if (outColor[1] < 0) outColor[1] = 0;
28 | if (outColor[2] < 0) outColor[2] = 0;
29 | data.OutTransform(outColor, outColor);
30 | }
31 | }
32 |
33 | ///
34 | /// Stores data about a conversion from to
35 | ///
36 | public sealed unsafe class Path_RGB_XYZ : ConversionPath
37 | {
38 | ///
39 | /// An array of commands that convert from to
40 | ///
41 | public override IConversionCommand[] Commands
42 | {
43 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
44 | }
45 |
46 | ///
47 | /// The conversion method
48 | ///
49 | /// The pointer to the input color values
50 | /// The pointer to the output color values
51 | /// The data that is used to perform the conversion
52 | public static void Convert(double* inColor, double* outColor, ConversionData data)
53 | {
54 | data.InTransform(inColor, outColor);
55 | UMath.MultiplyMatrix_3x3_3x1((double*)data.InSpaceData, outColor, outColor);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/LCHuv.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.Conversion
4 | {
5 | ///
6 | /// Stores data about a conversion from to
7 | ///
8 | public sealed unsafe class Path_Luv_LCHuv : ConversionPath
9 | {
10 | ///
11 | /// An array of commands that convert from to
12 | ///
13 | public override IConversionCommand[] Commands
14 | {
15 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
16 | }
17 |
18 | ///
19 | /// The conversion method
20 | ///
21 | /// The pointer to the input color values
22 | /// The pointer to the output color values
23 | /// The data that is used to perform the conversion
24 | public static void Convert(double* inColor, double* outColor, ConversionData data)
25 | {
26 | outColor[0] = inColor[0];
27 | outColor[1] = Math.Sqrt(inColor[1] * inColor[1] + inColor[2] * inColor[2]);
28 | outColor[2] = Math.Atan2(inColor[2], inColor[1]) * Const.Pi180_1;
29 | }
30 | }
31 |
32 | ///
33 | /// Stores data about a conversion from to
34 | ///
35 | public sealed unsafe class Path_LCHuv_Luv : ConversionPath
36 | {
37 | ///
38 | /// An array of commands that convert from to
39 | ///
40 | public override IConversionCommand[] Commands
41 | {
42 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
43 | }
44 |
45 | ///
46 | /// The conversion method
47 | ///
48 | /// The pointer to the input color values
49 | /// The pointer to the output color values
50 | /// The data that is used to perform the conversion
51 | public static void Convert(double* inColor, double* outColor, ConversionData data)
52 | {
53 | outColor[0] = Math.Abs(inColor[0]);
54 | outColor[1] = inColor[1] * Math.Cos(inColor[2] * Const.Pi180);
55 | outColor[2] = inColor[1] * Math.Sin(inColor[2] * Const.Pi180);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/DEF.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager.Conversion
3 | {
4 | ///
5 | /// Stores data about a conversion from to
6 | ///
7 | public sealed unsafe class Path_XYZ_DEF : ConversionPath
8 | {
9 | ///
10 | /// An array of commands that convert from to
11 | ///
12 | public override IConversionCommand[] Commands
13 | {
14 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert, new double[][] { XYZ_DEF_Matrix }) }; }
15 | }
16 |
17 | private static double[] XYZ_DEF_Matrix = { 0.2053, 0.7125, 0.4670, 1.8537, -1.2797, -0.4429, -0.3655, 1.0120, -0.6104 };
18 |
19 | ///
20 | /// The conversion method
21 | ///
22 | /// The pointer to the input color values
23 | /// The pointer to the output color values
24 | /// The data that is used to perform the conversion
25 | /// The matrix that is used to perform the conversion
26 | public static void Convert(double* inColor, double* outColor, ConversionData data, double** matrix)
27 | {
28 | UMath.MultiplyMatrix_3x3_3x1(matrix[0], inColor, outColor);
29 | }
30 | }
31 |
32 | ///
33 | /// Stores data about a conversion from to
34 | ///
35 | public sealed unsafe class Path_DEF_XYZ : ConversionPath
36 | {
37 | ///
38 | /// An array of commands that convert from to
39 | ///
40 | public override IConversionCommand[] Commands
41 | {
42 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert, new double[][] { DEF_XYZ_Matrix }) }; }
43 | }
44 |
45 | private static double[] DEF_XYZ_Matrix = { 0.671203, 0.495489, 0.153997, 0.706165, 0.0247732, 0.522292, 0.768864, -0.255621, -0.864558 };
46 |
47 | ///
48 | /// The conversion method
49 | ///
50 | /// The pointer to the input color values
51 | /// The pointer to the output color values
52 | /// The data that is used to perform the conversion
53 | /// The matrix that is used to perform the conversion
54 | public static void Convert(double* inColor, double* outColor, ConversionData data, double** matrix)
55 | {
56 | UMath.MultiplyMatrix_3x3_3x1(matrix[0], inColor, outColor);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/Bef.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.Conversion
4 | {
5 | ///
6 | /// Stores data about a conversion from to
7 | ///
8 | public sealed unsafe class Path_DEF_Bef : ConversionPath
9 | {
10 | ///
11 | /// An array of commands that convert from to
12 | ///
13 | public override IConversionCommand[] Commands
14 | {
15 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
16 | }
17 |
18 | ///
19 | /// The conversion method
20 | ///
21 | /// The pointer to the input color values
22 | /// The pointer to the output color values
23 | /// The data that is used to perform the conversion
24 | public static void Convert(double* inColor, double* outColor, ConversionData data)
25 | {
26 | outColor[0] = Math.Sqrt(inColor[0] * inColor[0] + inColor[1] * inColor[1] + inColor[2] * inColor[2]);
27 | if (Math.Abs(outColor[0]) < Const.Delta) outColor[1] = outColor[2] = 0;
28 | else
29 | {
30 | outColor[1] = inColor[1] / outColor[0];
31 | outColor[2] = inColor[2] / outColor[0];
32 | }
33 | }
34 | }
35 |
36 | ///
37 | /// Stores data about a conversion from to
38 | ///
39 | public sealed unsafe class Path_Bef_DEF : ConversionPath
40 | {
41 | ///
42 | /// An array of commands that convert from to
43 | ///
44 | public override IConversionCommand[] Commands
45 | {
46 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
47 | }
48 |
49 | ///
50 | /// The conversion method
51 | ///
52 | /// The pointer to the input color values
53 | /// The pointer to the output color values
54 | /// The data that is used to perform the conversion
55 | public static void Convert(double* inColor, double* outColor, ConversionData data)
56 | {
57 | double* vs = data.Vars;
58 |
59 | outColor[1] = inColor[1] * inColor[0];
60 | outColor[2] = inColor[2] * inColor[0];
61 | vs[0] = inColor[0] * inColor[0] - outColor[1] * outColor[1] - outColor[2] * outColor[2];
62 | if (vs[0] > 0) outColor[0] = Math.Sqrt(vs[0]);
63 | else outColor[0] = 0;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/ColorspaceICC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.ICC
4 | {
5 | ///
6 | /// Stores information and values of an ICC colorspace
7 | ///
8 | public class ColorspaceICC : Colorspace
9 | {
10 | ///
11 | /// The ICC profile of this colorspace
12 | ///
13 | public ICCProfile Profile
14 | {
15 | get { return _Profile; }
16 | }
17 | private ICCProfile _Profile;
18 |
19 | ///
20 | /// Creates a new instance of the class
21 | ///
22 | /// The ICC profile of this colorspace
23 | public ColorspaceICC(ICCProfile profile)
24 | : base(new WhitepointD50())//TODO: whitepoint is not always D50 for ICC profile
25 | {
26 | if (profile == null) throw new ArgumentNullException(nameof(profile));
27 | _Profile = profile;
28 | }
29 |
30 | ///
31 | /// Compares two colorspaces for their equality of values
32 | ///
33 | /// First colorspace
34 | /// Second colorspace
35 | /// True if they are the same, false otherwise
36 | public static bool operator ==(ColorspaceICC a, ColorspaceICC b)
37 | {
38 | if (ReferenceEquals(a, b)) return true;
39 | if ((object)a == null || (object)b == null) return false;
40 | return a.Profile == b.Profile;
41 | }
42 | ///
43 | /// Compares two colorspaces for their inequality of values
44 | ///
45 | /// First colorspace
46 | /// Second colorspace
47 | /// False if they are the same, true otherwise
48 | public static bool operator !=(ColorspaceICC a, ColorspaceICC b)
49 | {
50 | return !(a == b);
51 | }
52 | ///
53 | /// Compares this colorspace with another for their equality of values
54 | ///
55 | /// The colorspace to compare to
56 | /// True if they are the same, false otherwise
57 | public override bool Equals(object obj)
58 | {
59 | ColorspaceICC c = obj as ColorspaceICC;
60 | if ((object)c == null) return base.Equals(obj);
61 | return c == this;
62 | }
63 | ///
64 | /// Calculates a hash code of this colorspace
65 | ///
66 | /// The hash code of this colorspace
67 | public override int GetHashCode()
68 | {
69 | unchecked
70 | {
71 | int hash = (int)2166136261;
72 | hash *= 16777619 ^ Profile.GetHashCode();
73 | return hash;
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/Conversions/XYZ_DEF.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace ColorManagerTests.Conversions
5 | {
6 | [TestClass]
7 | public unsafe class XYZ_DEF : Conversion
8 | {
9 | protected override double[] Rand_In_T
10 | {
11 | get { return new double[] { 0.454626246521, 0.046609673694, 0.43789408225 }; }
12 | }
13 | protected override double[] Rand_Out_U
14 | {
15 | get { return new double[] { 0.331040697328, 0.58915098472, -0.38628745113 }; }
16 | }
17 | protected override double[] Min_Out_U
18 | {
19 | get { return new double[] { 0.0, 0.0, 0.0 }; }
20 | }
21 | protected override double[] Max_Out_U
22 | {
23 | get { return new double[] { 1.3848, 0.1311, 0.0361 }; }
24 | }
25 | protected override double[] Rand_In_U
26 | {
27 | get { return new double[] { 0.454626246521, 0.046609673694, 0.43789408225 }; }
28 | }
29 | protected override double[] Rand_Out_T
30 | {
31 | get { return new double[] { 0.395675456137, 0.550904390149, -0.040953488956 }; }
32 | }
33 | protected override double[] Min_Out_T
34 | {
35 | get { return new double[] { 0.0, 0.0, 0.0 }; }
36 | }
37 | protected override double[] Max_Out_T
38 | {
39 | get { return new double[] { 1.320689, 1.2532302, -0.351315 }; }
40 | }
41 |
42 | protected override double[][] AdditionalDataToT
43 | {
44 | get { return new double[][] { DEF_XYZ_Matrix }; }
45 | }
46 | protected override double[][] AdditionalDataToU
47 | {
48 | get { return new double[][] { XYZ_DEF_Matrix }; }
49 | }
50 |
51 | private static double[] XYZ_DEF_Matrix = { 0.2053, 0.7125, 0.4670, 1.8537, -1.2797, -0.4429, -0.3655, 1.0120, -0.6104 };
52 | private static double[] DEF_XYZ_Matrix = { 0.671203, 0.495489, 0.153997, 0.706165, 0.0247732, 0.522292, 0.768864, -0.255621, -0.864558 };
53 |
54 | public XYZ_DEF() : base(new ColorXYZ(Whitepoint.D65),
55 | new ColorDEF(Whitepoint.D65))
56 | { }
57 |
58 | [TestMethod]
59 | public void XYZ_DEF_Random()
60 | {
61 | T_U_Random();
62 | }
63 |
64 | [TestMethod]
65 | public void XYZ_DEF_Min()
66 | {
67 | T_U_Min();
68 | }
69 |
70 | [TestMethod]
71 | public void XYZ_DEF_Max()
72 | {
73 | T_U_Max();
74 | }
75 |
76 | [TestMethod]
77 | public void DEF_XYZ_Random()
78 | {
79 | U_T_Random();
80 | }
81 |
82 | [TestMethod]
83 | public void DEF_XYZ_Min()
84 | {
85 | U_T_Min();
86 | }
87 |
88 | [TestMethod]
89 | public void DEF_XYZ_Max()
90 | {
91 | U_T_Max();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ColorManager/ColorDifference/ColorDifference_CIE94.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.ColorDifference
4 | {
5 | ///
6 | /// Provides methods to calculate the difference between two colors by the CIE94 formula
7 | ///
8 | public unsafe sealed class ColorDifference_CIE94 : ColorLabDifferenceCalculator
9 | {
10 | ///
11 | /// Creates a new instance of the class
12 | ///
13 | /// First color to compare
14 | /// Second color to compare
15 | public ColorDifference_CIE94(ColorLab Color1, ColorLab Color2)
16 | : base(Color1, Color2)
17 | { }
18 |
19 | ///
20 | /// Calculate the difference between two colors
21 | ///
22 | /// The difference between Color1 and Color2
23 | public override double DeltaE()
24 | {
25 | return DeltaE(1, 0.045, 0.015); //CIE94DifferenceMethod.GraphicArts
26 | }
27 |
28 | ///
29 | /// Calculate the difference between two colors
30 | ///
31 | /// The specific way to calculate the difference
32 | /// The difference between Color1 and Color2
33 | public double DeltaE(CIE94DifferenceMethod DiffMethod)
34 | {
35 | switch (DiffMethod)
36 | {
37 | case CIE94DifferenceMethod.GraphicArts:
38 | return DeltaE(1, 0.045, 0.015);
39 | case CIE94DifferenceMethod.Textiles:
40 | return DeltaE(2, 0.048, 0.014);
41 |
42 | default:
43 | throw new ArgumentException("Not a valid enum value");
44 | }
45 | }
46 |
47 | ///
48 | /// Calculate the difference between two colors
49 | ///
50 | /// SL parameter
51 | /// K1 parameter
52 | /// K2 parameter
53 | /// The difference between Color1 and Color2
54 | public double DeltaE(double SL, double K1, double K2)
55 | {
56 | Vars[1] = Math.Sqrt(Col1Values[1] * Col1Values[1] + Col1Values[2] * Col1Values[2]); //C1
57 | Vars[2] = Math.Sqrt(Col2Values[1] * Col2Values[1] + Col2Values[2] * Col2Values[2]); //C2
58 |
59 | Vars[6] = Col1Values[1] - Col2Values[1];
60 | Vars[7] = Col1Values[2] - Col2Values[2];
61 | Vars[8] = Vars[1] - Vars[2];
62 |
63 | Vars[5] = Vars[6] * Vars[6] + Vars[7] * Vars[7] - Vars[8] * Vars[8];
64 |
65 | Vars[0] = (Col1Values[0] - Col2Values[0]) / SL;
66 | Vars[3] = Vars[8] / (1 + K1 * Vars[1]);
67 | Vars[4] = 1 + K2 * Vars[1];
68 |
69 | return Math.Sqrt(Vars[0] * Vars[0] + Vars[3] * Vars[3] + Vars[5] / (Vars[4] * Vars[4]));
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/ColorDifferences/CD_DIN99.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.ColorDifference;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace ColorManagerTests.ColorDifferences
6 | {
7 | [TestClass]
8 | public unsafe class CD_DIN99 : ColorDifference
9 | {
10 | public override double[] DeltaCOutput
11 | {
12 | get { return new double[] { -1.450737747574, -23.825848332292 }; }
13 | }
14 | public override double[] DeltaEOutput
15 | {
16 | get { return new double[] { 46.101985083368, 54.81611834892 }; }
17 | }
18 | public override double[] DeltaHOutput
19 | {
20 | get { return new double[] { 16.846699537289, -41.006448934528 }; }
21 | }
22 |
23 | [TestMethod]
24 | public override void DeltaC()
25 | {
26 | var col1 = new ColorLCH99(62.487821480021, 7.729473035191, 277.020495107873);
27 | var col2 = new ColorLCH99(19.598695779964, 9.180210782765, 96.023577519703);
28 |
29 | using (var cdc = new ColorDifference_DIN99(col1, col2))
30 | {
31 | DeltaC(cdc, 0);
32 |
33 | col1[0] = 34.58548699952;
34 | col1[1] = 21.236276234843;
35 | col1[2] = 285.18673975169;
36 |
37 | col2[0] = 62.073792292305;
38 | col2[1] = 45.062124567135;
39 | col2[2] = 202.160452968516;
40 |
41 | DeltaC(cdc, 1);
42 | }
43 | }
44 |
45 | [TestMethod]
46 | public override void DeltaE()
47 | {
48 | var col1 = new ColorLCH99(62.487821480021, 7.729473035191, 277.020495107873);
49 | var col2 = new ColorLCH99(19.598695779964, 9.180210782765, 96.023577519703);
50 |
51 | using (var cdc = new ColorDifference_DIN99(col1, col2))
52 | {
53 | DeltaE(cdc, 0);
54 |
55 | col1[0] = 34.58548699952;
56 | col1[1] = 21.236276234843;
57 | col1[2] = 285.18673975169;
58 |
59 | col2[0] = 62.073792292305;
60 | col2[1] = 45.062124567135;
61 | col2[2] = 202.160452968516;
62 |
63 | DeltaE(cdc, 1);
64 | }
65 | }
66 |
67 | [TestMethod]
68 | public override void DeltaH()
69 | {
70 | var col1 = new ColorLCH99(62.487821480021, 7.729473035191, 277.020495107873);
71 | var col2 = new ColorLCH99(19.598695779964, 9.180210782765, 96.023577519703);
72 |
73 | using (var cdc = new ColorDifference_DIN99(col1, col2))
74 | {
75 | DeltaH(cdc, 0);
76 |
77 | col1[0] = 34.58548699952;
78 | col1[1] = 21.236276234843;
79 | col1[2] = 285.18673975169;
80 |
81 | col2[0] = 62.073792292305;
82 | col2[1] = 45.062124567135;
83 | col2[2] = 202.160452968516;
84 |
85 | DeltaH(cdc, 1);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ColorManager/Base/ChromaticAdaption.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ColorManager.Conversion;
3 |
4 | namespace ColorManager
5 | {
6 | ///
7 | /// Represents a chromatic adaption method (abstract class)
8 | ///
9 | public abstract class ChromaticAdaption
10 | {
11 | ///
12 | /// The type of color this chromatic adaption is performed on
13 | ///
14 | public abstract Type ColorType { get; }
15 | ///
16 | /// The method to execute to do the chromatic adaption
17 | ///
18 | public abstract ConversionDelegate Method { get; }
19 |
20 | ///
21 | /// Gets the conversion data necessary for the chromatic adaption
22 | ///
23 | /// The data that is used to perform the chromatic adaption
24 | /// The conversion data necessary for the chromatic adaption
25 | public abstract CustomData GetCAData(ConversionData data);
26 |
27 | ///
28 | /// Compares two chromatic adaption methods for their equality of the color type
29 | ///
30 | /// First color
31 | /// Second color
32 | /// True if they are the same, false otherwise
33 | public static bool operator ==(ChromaticAdaption a, ChromaticAdaption b)
34 | {
35 | if (ReferenceEquals(a, b)) return true;
36 | if ((object)a == null || (object)b == null) return false;
37 | return a.ColorType == b.ColorType;
38 | }
39 | ///
40 | /// Compares two chromatic adaption methods for their inequality of the color type
41 | ///
42 | /// First color
43 | /// Second color
44 | /// False if they are the same, true otherwise
45 | public static bool operator !=(ChromaticAdaption a, ChromaticAdaption b)
46 | {
47 | return !(a == b);
48 | }
49 | ///
50 | /// Compares this chromatic adaption method with another for their equality of the color type
51 | ///
52 | /// The color to compare to
53 | /// True if they are the same, false otherwise
54 | public override bool Equals(object obj)
55 | {
56 | ChromaticAdaption c = obj as ChromaticAdaption;
57 | if ((object)c == null) return false;
58 | return c == this;
59 | }
60 | ///
61 | /// Calculates a hash code of this chromatic adaption method
62 | ///
63 | /// The hash code of this color
64 | public override int GetHashCode()
65 | {
66 | unchecked
67 | {
68 | int hash = (int)2166136261;
69 | hash *= 16777619 ^ ColorType.GetHashCode();
70 | return hash;
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ColorManager/Colors/Base/ColorLCH99Base.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ColorManager
3 | {
4 | ///
5 | /// Base class for LCH99 colors (abstract class)
6 | ///
7 | public abstract class ColorLCH99Base : ColorLCHBase
8 | {
9 | #region Variables
10 |
11 | ///
12 | /// Minimum value for each channel
13 | ///
14 | public override double[] MinValues
15 | {
16 | get { return new double[] { Min_L, Min_C, Min_H }; }
17 | }
18 | ///
19 | /// Maximum value for each channel
20 | ///
21 | public override double[] MaxValues
22 | {
23 | get { return new double[] { Max_L, Max_C, Max_H }; }
24 | }
25 |
26 | ///
27 | /// Minimum value for each channel
28 | ///
29 | public static double[] Min
30 | {
31 | get { return new double[] { Min_L, Min_C, Min_H }; }
32 | }
33 | ///
34 | /// Maximum value for each channel
35 | ///
36 | public static double[] Max
37 | {
38 | get { return new double[] { Max_L, Max_C, Max_H }; }
39 | }
40 |
41 | ///
42 | /// Minimum value for the channel
43 | ///
44 | public static readonly double Min_L = 0.0;
45 | ///
46 | /// Minimum value for the channel
47 | ///
48 | public static readonly double Min_C = 0.0;
49 | ///
50 | /// Minimum value for the channel
51 | ///
52 | public static readonly double Min_H = 0.0;
53 |
54 | ///
55 | /// Maximum value for the channel
56 | ///
57 | public static readonly double Max_L = 100.0;
58 | ///
59 | /// Maximum value for the channel
60 | ///
61 | public static readonly double Max_C = 70.0;
62 | ///
63 | /// Maximum value for the channel
64 | ///
65 | public static readonly double Max_H = 360.0;
66 |
67 | private static readonly Whitepoint wp = new WhitepointD65();
68 |
69 | #endregion
70 |
71 | ///
72 | /// Creates a new instance of the class
73 | ///
74 | public ColorLCH99Base()
75 | : base(wp)
76 | { }
77 |
78 | ///
79 | /// Creates a new instance of the class
80 | ///
81 | /// Value for the Lightness channel
82 | /// Value for the Chroma channel
83 | /// Value for the Hue channel
84 | public ColorLCH99Base(double L, double C, double H)
85 | : base(L, C, H, wp)
86 | { }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ColorManager/Conversions/Yxy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager.Conversion
4 | {
5 | ///
6 | /// Stores data about a conversion from to
7 | ///
8 | public sealed unsafe class Path_XYZ_Yxy : ConversionPath
9 | {
10 | ///
11 | /// An array of commands that convert from to
12 | ///
13 | public override IConversionCommand[] Commands
14 | {
15 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
16 | }
17 |
18 | ///
19 | /// The conversion method
20 | ///
21 | /// The pointer to the input color values
22 | /// The pointer to the output color values
23 | /// The data that is used to perform the conversion
24 | public static void Convert(double* inColor, double* outColor, ConversionData data)
25 | {
26 | double* vs = data.Vars;
27 |
28 | outColor[0] = inColor[1];
29 | vs[0] = inColor[0] + inColor[1] + inColor[2];
30 | if (Math.Abs(vs[0]) < Const.Delta)
31 | {
32 | outColor[1] = data.OutWPCr[0];
33 | outColor[2] = data.OutWPCr[1];
34 | }
35 | else
36 | {
37 | vs[0] = 1d / vs[0];
38 | outColor[2] = inColor[1] * vs[0];
39 | outColor[1] = inColor[0] * vs[0];
40 | }
41 | }
42 | }
43 |
44 | ///
45 | /// Stores data about a conversion from to
46 | ///
47 | public sealed unsafe class Path_Yxy_XYZ : ConversionPath
48 | {
49 | ///
50 | /// An array of commands that convert from to
51 | ///
52 | public override IConversionCommand[] Commands
53 | {
54 | get { return new IConversionCommand[] { new CC_ExecuteMethod(Convert) }; }
55 | }
56 |
57 | ///
58 | /// The conversion method
59 | ///
60 | /// The pointer to the input color values
61 | /// The pointer to the output color values
62 | /// The data that is used to perform the conversion
63 | public static void Convert(double* inColor, double* outColor, ConversionData data)
64 | {
65 | if (inColor[2] < Const.Delta) outColor[0] = outColor[1] = outColor[2] = 0;
66 | else
67 | {
68 | double* vs = data.Vars;
69 | vs[0] = 1d / inColor[2];
70 | outColor[1] = inColor[0];
71 | outColor[0] = (inColor[1] * inColor[0]) * vs[0];
72 | outColor[2] = ((1 - inColor[1] - inColor[2]) * inColor[0]) * vs[0];
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/ColorDifferences/CD_CMC.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.ColorDifference;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace ColorManagerTests.ColorDifferences
6 | {
7 | [TestClass]
8 | public unsafe class CD_CMC : ColorDifference
9 | {
10 | public override double[] DeltaCOutput
11 | {
12 | get { return new double[] { -2.350194091289, 7.221956402131 }; }
13 | }
14 | public override double[] DeltaEOutput
15 | {
16 | get { return new double[] { 95.953655648734, 36.27469483365 }; }
17 | }
18 | public override double[] DeltaHOutput
19 | {
20 | get { return new double[] { 187.867511692714, 48.961146434267 }; }
21 | }
22 |
23 | [TestMethod]
24 | public override void DeltaC()
25 | {
26 | var col1 = new ColorLab(56.54364036468, -116.587189881288, 0.552391820495, Whitepoint.D65);
27 | var col2 = new ColorLab(15.649015053943, 31.881040123352, -114.586263900197, Whitepoint.D65);
28 |
29 | using (var cdc = new ColorDifference_CMC(col1, col2))
30 | {
31 | DeltaC(cdc, 0);
32 |
33 | col1[0] = 31.310532664093;
34 | col1[1] = 81.583387114612;
35 | col1[2] = -41.510887980932;
36 |
37 | col2[0] = 36.092706008857;
38 | col2[1] = 83.941777394475;
39 | col2[2] = 7.923801354796;
40 |
41 | DeltaC(cdc, 1);
42 | }
43 | }
44 |
45 | [TestMethod]
46 | public override void DeltaE()
47 | {
48 | var col1 = new ColorLab(56.54364036468, -116.587189881288, 0.552391820495, Whitepoint.D65);
49 | var col2 = new ColorLab(15.649015053943, 31.881040123352, -114.586263900197, Whitepoint.D65);
50 |
51 | using (var cdc = new ColorDifference_CMC(col1, col2))
52 | {
53 | DeltaE(cdc, 0);
54 |
55 | col1[0] = 31.310532664093;
56 | col1[1] = 81.583387114612;
57 | col1[2] = -41.510887980932;
58 |
59 | col2[0] = 36.092706008857;
60 | col2[1] = 83.941777394475;
61 | col2[2] = 7.923801354796;
62 |
63 | DeltaE(cdc, 1);
64 | }
65 | }
66 |
67 | [TestMethod]
68 | public override void DeltaH()
69 | {
70 | var col1 = new ColorLab(56.54364036468, -116.587189881288, 0.552391820495, Whitepoint.D65);
71 | var col2 = new ColorLab(15.649015053943, 31.881040123352, -114.586263900197, Whitepoint.D65);
72 |
73 | using (var cdc = new ColorDifference_CMC(col1, col2))
74 | {
75 | DeltaH(cdc, 0);
76 |
77 | col1[0] = 31.310532664093;
78 | col1[1] = 81.583387114612;
79 | col1[2] = -41.510887980932;
80 |
81 | col2[0] = 36.092706008857;
82 | col2[1] = 83.941777394475;
83 | col2[2] = 7.923801354796;
84 |
85 | DeltaH(cdc, 1);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/ColorDifferences/CD_CIE94.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.ColorDifference;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace ColorManagerTests.ColorDifferences
6 | {
7 | [TestClass]
8 | public unsafe class CD_CIE94 : ColorDifference
9 | {
10 | public override double[] DeltaCOutput
11 | {
12 | get { return new double[] { -17.801131119653, -43.315605043277 }; }
13 | }
14 | public override double[] DeltaEOutput
15 | {
16 | get { return new double[] { 62.264246596784, 55.144345225101 }; }
17 | }
18 | public override double[] DeltaHOutput
19 | {
20 | get { return new double[] { 61.172362727893, 70.459648338603 }; }
21 | }
22 |
23 | [TestMethod]
24 | public override void DeltaC()
25 | {
26 | var col1 = new ColorLab(35.679418652169, 3.282836838408, -40.730857987297, Whitepoint.D65);
27 | var col2 = new ColorLab(84.660455880063, -56.01410114533, -17.43254524571, Whitepoint.D65);
28 |
29 | using (var cdc = new ColorDifference_CIE94(col1, col2))
30 | {
31 | DeltaC(cdc, 0);
32 |
33 | col1[0] = 83.955578740665;
34 | col1[1] = -31.540876770993;
35 | col1[2] = 41.770289617833;
36 |
37 | col2[0] = 47.674533462932;
38 | col2[1] = -94.988220274094;
39 | col2[2] = -11.288529504574;
40 |
41 | DeltaC(cdc, 1);
42 | }
43 | }
44 |
45 | [TestMethod]
46 | public override void DeltaE()
47 | {
48 | var col1 = new ColorLab(35.679418652169, 3.282836838408, -40.730857987297, Whitepoint.D65);
49 | var col2 = new ColorLab(84.660455880063, -56.01410114533, -17.43254524571, Whitepoint.D65);
50 |
51 | using (var cdc = new ColorDifference_CIE94(col1, col2))
52 | {
53 | DeltaE(cdc, 0);
54 |
55 | col1[0] = 83.955578740665;
56 | col1[1] = -31.540876770993;
57 | col1[2] = 41.770289617833;
58 |
59 | col2[0] = 47.674533462932;
60 | col2[1] = -94.988220274094;
61 | col2[2] = -11.288529504574;
62 |
63 | DeltaE(cdc, 1);
64 | }
65 | }
66 |
67 | [TestMethod]
68 | public override void DeltaH()
69 | {
70 | var col1 = new ColorLab(35.679418652169, 3.282836838408, -40.730857987297, Whitepoint.D65);
71 | var col2 = new ColorLab(84.660455880063, -56.01410114533, -17.43254524571, Whitepoint.D65);
72 |
73 | using (var cdc = new ColorDifference_CIE94(col1, col2))
74 | {
75 | DeltaH(cdc, 0);
76 |
77 | col1[0] = 83.955578740665;
78 | col1[1] = -31.540876770993;
79 | col1[2] = 41.770289617833;
80 |
81 | col2[0] = 47.674533462932;
82 | col2[1] = -94.988220274094;
83 | col2[2] = -11.288529504574;
84 |
85 | DeltaH(cdc, 1);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/ColorDifferences/CD_CIEDE2000.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.ColorDifference;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace ColorManagerTests.ColorDifferences
6 | {
7 | [TestClass]
8 | public unsafe class CD_CIEDE2000 : ColorDifference
9 | {
10 | public override double[] DeltaCOutput
11 | {
12 | get { return new double[] { 29.611104267226, -90.365805972086 }; }
13 | }
14 | public override double[] DeltaEOutput
15 | {
16 | get { return new double[] { 14.775798101291, 32.674856271668 }; }
17 | }
18 | public override double[] DeltaHOutput
19 | {
20 | get { return new double[] { 6.800448372164, 72.150267072391 }; }
21 | }
22 |
23 | [TestMethod]
24 | public override void DeltaC()
25 | {
26 | var col1 = new ColorLab(18.551095437049, 39.859850965957, 20.274218251707, Whitepoint.D65);
27 | var col2 = new ColorLab(25.476424833982, 11.229184491085, 10.108170288432, Whitepoint.D65);
28 |
29 | using (var cdc = new ColorDifference_CIEDE2000(col1, col2))
30 | {
31 | DeltaC(cdc, 0);
32 |
33 | col1[0] = 36.059942741906;
34 | col1[1] = 2.972650137135;
35 | col1[2] = -14.453191817134;
36 |
37 | col2[0] = 50.756107743716;
38 | col2[1] = 61.327442426853;
39 | col2[2] = 85.37845719472;
40 |
41 | DeltaC(cdc, 1);
42 | }
43 | }
44 |
45 | [TestMethod]
46 | public override void DeltaE()
47 | {
48 | var col1 = new ColorLab(18.551095437049, 39.859850965957, 20.274218251707, Whitepoint.D65);
49 | var col2 = new ColorLab(25.476424833982, 11.229184491085, 10.108170288432, Whitepoint.D65);
50 |
51 | using (var cdc = new ColorDifference_CIEDE2000(col1, col2))
52 | {
53 | DeltaE(cdc, 0);
54 |
55 | col1[0] = 36.059942741906;
56 | col1[1] = 2.972650137135;
57 | col1[2] = -14.453191817134;
58 |
59 | col2[0] = 50.756107743716;
60 | col2[1] = 61.327442426853;
61 | col2[2] = 85.37845719472;
62 |
63 | DeltaE(cdc, 1);
64 | }
65 | }
66 |
67 | [TestMethod]
68 | public override void DeltaH()
69 | {
70 | var col1 = new ColorLab(18.551095437049, 39.859850965957, 20.274218251707, Whitepoint.D65);
71 | var col2 = new ColorLab(25.476424833982, 11.229184491085, 10.108170288432, Whitepoint.D65);
72 |
73 | using (var cdc = new ColorDifference_CIEDE2000(col1, col2))
74 | {
75 | DeltaH(cdc, 0);
76 |
77 | col1[0] = 36.059942741906;
78 | col1[1] = 2.972650137135;
79 | col1[2] = -14.453191817134;
80 |
81 | col2[0] = 50.756107743716;
82 | col2[1] = 61.327442426853;
83 | col2[2] = 85.37845719472;
84 |
85 | DeltaH(cdc, 1);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ColorManagerTests/Color/ColorDifferences/CD_CIE76.cs:
--------------------------------------------------------------------------------
1 | using ColorManager;
2 | using ColorManager.ColorDifference;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace ColorManagerTests.ColorDifferences
6 | {
7 | [TestClass]
8 | public unsafe class CD_CIE76 : ColorDifference
9 | {
10 | public override double[] DeltaCOutput
11 | {
12 | get { return new double[] { 48.022926228728, -7.527620345142 }; }
13 | }
14 | public override double[] DeltaEOutput
15 | {
16 | get { return new double[] { 76.360760302964, 118.208035285292 }; }
17 | }
18 | public override double[] DeltaHOutput
19 | {
20 | get { return new double[] { 59.166053650281, 113.189187031759 }; }
21 | }
22 |
23 | [TestMethod]
24 | public override void DeltaC()
25 | {
26 | var col1 = new ColorLab(78.012070941279, -109.730946283313, -69.750359159196, Whitepoint.D65);
27 | var col2 = new ColorLab(82.925559104386, -33.693161514678, -74.75821654499, Whitepoint.D65);
28 |
29 | using (var cdc = new ColorDifference_CIE76(col1, col2))
30 | {
31 | DeltaC(cdc, 0);
32 |
33 | col1[0] = 39.920151608493;
34 | col1[1] = -41.740163183534;
35 | col1[2] = -109.078609910248;
36 |
37 | col2[0] = 6.683387670984;
38 | col2[1] = -121.116973366992;
39 | col2[2] = -28.036774207506;
40 |
41 | DeltaC(cdc, 1);
42 | }
43 | }
44 |
45 | [TestMethod]
46 | public override void DeltaE()
47 | {
48 | var col1 = new ColorLab(78.012070941279, -109.730946283313, -69.750359159196, Whitepoint.D65);
49 | var col2 = new ColorLab(82.925559104386, -33.693161514678, -74.75821654499, Whitepoint.D65);
50 |
51 | using (var cdc = new ColorDifference_CIE76(col1, col2))
52 | {
53 | DeltaE(cdc, 0);
54 |
55 | col1[0] = 39.920151608493;
56 | col1[1] = -41.740163183534;
57 | col1[2] = -109.078609910248;
58 |
59 | col2[0] = 6.683387670984;
60 | col2[1] = -121.116973366992;
61 | col2[2] = -28.036774207506;
62 |
63 | DeltaE(cdc, 1);
64 | }
65 | }
66 |
67 | [TestMethod]
68 | public override void DeltaH()
69 | {
70 | var col1 = new ColorLab(78.012070941279, -109.730946283313, -69.750359159196, Whitepoint.D65);
71 | var col2 = new ColorLab(82.925559104386, -33.693161514678, -74.75821654499, Whitepoint.D65);
72 |
73 | using (var cdc = new ColorDifference_CIE76(col1, col2))
74 | {
75 | DeltaH(cdc, 0);
76 |
77 | col1[0] = 39.920151608493;
78 | col1[1] = -41.740163183534;
79 | col1[2] = -109.078609910248;
80 |
81 | col2[0] = 6.683387670984;
82 | col2[1] = -121.116973366992;
83 | col2[2] = -28.036774207506;
84 |
85 | DeltaH(cdc, 1);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/UI/ColorConverterLib/ColorConverterLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {5D47A675-01D4-4B18-8627-5BDF21CE0A1F}
8 | Library
9 | ColorConverter
10 | ColorConverterLib
11 | v4.5
12 | true
13 |
14 |
15 | true
16 | full
17 | false
18 | bin\Debug
19 | DEBUG;TRACE
20 | prompt
21 | 4
22 |
23 |
24 | pdbonly
25 | true
26 | bin\Release
27 | TRACE
28 | prompt
29 | 4
30 |
31 |
32 |
33 | ..\..\packages\Eto.Forms.2.2.0\lib\net45\Eto.dll
34 |
35 |
36 | ..\..\packages\Eto.Serialization.Xaml.2.2.0\lib\net45\Eto.Serialization.Xaml.dll
37 |
38 |
39 | ..\..\packages\Portable.Xaml.0.6.1\lib\dotnet\Portable.Xaml.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 | ColorControl.xeto
47 |
48 |
49 |
50 | Designer
51 |
52 |
53 | MainForm.xeto
54 |
55 |
56 |
57 |
58 | Designer
59 |
60 |
61 |
62 |
63 |
64 | {80ce271c-3b13-4658-afb8-26b481165e1c}
65 | ColorManager
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_CIERGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an CIERGB colorspace
7 | ///
8 | public sealed class Colorspace_CIERGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "CIERGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.735, 0.265 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.274, 0.717 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.167, 0.009 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.488718, 0.3106803, 0.2006017, 0.1762044, 0.8129847, 0.0108109, 0.0, 0.0102048, 0.9897952 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 2.3706743, -0.9000405, -0.4706338, -0.513885, 1.4253036, 0.0885814, 0.0052982, -0.0146949, 1.0093968 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointE();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_CIERGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_NTSCRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an NTSCRGB colorspace
7 | ///
8 | public sealed class Colorspace_NTSCRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "NTSCRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.67, 0.33 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.21, 0.71 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.14, 0.08 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.6068909, 0.1735011, 0.200348, 0.2989164, 0.586599, 0.1144845, 0.0, 0.0660957, 1.1162243 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.9099961, -0.5324542, -0.2882091, -0.9846663, 1.999171, -0.0283082, 0.0583056, -0.1183781, 0.8975535 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointC();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_NTSCRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_BetaRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an BetaRGB colorspace
7 | ///
8 | public sealed class Colorspace_BetaRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "BetaRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.6888, 0.3112 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.1986, 0.7551 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.1265, 0.0352 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.6712537, 0.1745834, 0.1183829, 0.3032726, 0.6637861, 0.0329413, 0.0, 0.040701, 0.784509 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.683227, -0.4282363, -0.2360185, -0.7710229, 1.7065571, 0.04469, 0.0400013, -0.0885376, 1.272364 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_BetaRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_AdobeRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an AdobeRGB colorspace
7 | ///
8 | public sealed class Colorspace_AdobeRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "AdobeRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.64, 0.33 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.21, 0.71 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.15, 0.06 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.5767309, 0.185554, 0.1881852, 0.2973769, 0.6273491, 0.0752741, 0.0270343, 0.0706872, 0.9911085 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 2.041369, -0.5649464, -0.3446944, -0.969266, 1.8760108, 0.041556, 0.0134474, -0.1183897, 1.0154096 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD65();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_AdobeRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_AppleRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an AppleRGB colorspace
7 | ///
8 | public sealed class Colorspace_AppleRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "AppleRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.625, 0.34 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.28, 0.595 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.155, 0.07 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.4497288, 0.3162486, 0.1844926, 0.2446525, 0.6720283, 0.0833192, 0.0251848, 0.1411824, 0.9224628 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 2.9515373, -1.2894116, -0.4738445, -1.0851093, 1.9908566, 0.0372026, 0.0854934, -0.2694964, 1.0912975 }; }
58 | }
59 |
60 | private const double g = 1.8d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD65();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_AppleRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_BruceRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an BruceRGB colorspace
7 | ///
8 | public sealed class Colorspace_BruceRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "BruceRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.64, 0.33 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.28, 0.65 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.15, 0.06 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.4674162, 0.2944512, 0.1886026, 0.2410115, 0.6835475, 0.075441, 0.0219101, 0.0736128, 0.9933071 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 2.7454669, -1.1358136, -0.4350269, -0.969266, 1.8760108, 0.041556, 0.0112723, -0.1139754, 1.0132541 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD65();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_BruceRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_DonRGB4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an DonRGB4 colorspace
7 | ///
8 | public sealed class Colorspace_DonRGB4 : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "DonRGB4"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.696, 0.3 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.215, 0.765 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.13, 0.035 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.6457711, 0.1933511, 0.1250978, 0.2783496, 0.6879702, 0.0336802, 0.0037113, 0.0179861, 0.8035125 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.7603902, -0.4881198, -0.2536126, -0.7126288, 1.6527432, 0.0416715, 0.0078207, -0.0347411, 1.2447743 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_DonRGB4()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_ProPhotoRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an ProPhotoRGB colorspace
7 | ///
8 | public sealed class Colorspace_ProPhotoRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "ProPhotoRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.7347, 0.2653 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.1596, 0.8404 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.0366, 0.0001 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.7976749, 0.1351917, 0.0313534, 0.2880402, 0.7118741, 0.0000857, 0.0, 0.0, 0.8252100 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.3459433, -0.2556075, -0.0511118, -0.5445989, 1.5081673, 0.0205351, 0.0, 0.0, 1.2118128 }; }
58 | }
59 |
60 | private const double g = 1.8d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_ProPhotoRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_BestRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an BestRGB colorspace
7 | ///
8 | public sealed class Colorspace_BestRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "BestRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.7347, 0.2653 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.215, 0.775 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.13, 0.035 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.6326696, 0.2045558, 0.1269946, 0.2284569, 0.7373523, 0.0341908, 0.0000000, 0.0095142, 0.8156958 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.7552599, -0.4836786, -0.2530000, -0.5441336, 1.5068789, 0.0215528, 0.0063467, -0.0175761, 1.2256959 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_BestRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_PAL_SECAMRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an PAL SECAMRGB colorspace
7 | ///
8 | public sealed class Colorspace_PAL_SECAMRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "PAL_SECAMRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.64, 0.33 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.29, 0.6 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.15, 0.06 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.430619, 0.3415419, 0.1783091, 0.2220379, 0.7066384, 0.0713236, 0.0201853, 0.1295504, 0.9390944 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 3.0628971, -1.3931791, -0.4757517, -0.969266, 1.8760108, 0.041556, 0.0678775, -0.2288548, 1.069349 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD65();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_PAL_SECAMRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_SMPTE_C_RGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an SMPTE C RGB colorspace
7 | ///
8 | public sealed class Colorspace_SMPTE_C_RGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "SMPTE_C_RGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.63, 0.34 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.31, 0.595 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.155, 0.07 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.3935891, 0.3652497, 0.1916313, 0.2124132, 0.7010437, 0.0865432, 0.0187423, 0.1119313, 0.9581563 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 3.505396, -1.7394894, -0.5439640, -1.0690722, 1.9778245, 0.0351722, 0.05632, -0.1970226, 1.0502026 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD65();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_SMPTE_C_RGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_EktaSpacePS5.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an EktaSpacePS5 RGB colorspace
7 | ///
8 | public sealed class Colorspace_EktaSpacePS5 : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "EktaSpacePS5"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.695, 0.305 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.26, 0.7 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.11, 0.005 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.5938914, 0.2729801, 0.0973485, 0.2606286, 0.7349465, 0.0044249, 0.0, 0.0419969, 0.7832131 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 2.0043819, -0.7304844, -0.2450052, -0.7110285, 1.6202126, 0.0792227, 0.0381263, -0.086878, 1.2725438 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_EktaSpacePS5()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ColorManager/Colorspaces/RGB/Colorspace_WideGamutRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ColorManager
4 | {
5 | ///
6 | /// Stores information and values of an WideGamutRGB colorspace
7 | ///
8 | public sealed class Colorspace_WideGamutRGB : ColorspaceRGB
9 | {
10 | ///
11 | /// Name of the colorspace
12 | ///
13 | public override string Name
14 | {
15 | get { return "WideGamutRGB"; }
16 | }
17 | ///
18 | /// The gamma value
19 | ///
20 | public override double Gamma
21 | {
22 | get { return g; }
23 | }
24 | ///
25 | /// Red primary
26 | ///
27 | public override double[] Cr
28 | {
29 | get { return new double[] { 0.735, 0.265 }; }
30 | }
31 | ///
32 | /// Green primary
33 | ///
34 | public override double[] Cg
35 | {
36 | get { return new double[] { 0.115, 0.826 }; }
37 | }
38 | ///
39 | /// Blue primary
40 | ///
41 | public override double[] Cb
42 | {
43 | get { return new double[] { 0.157, 0.018 }; }
44 | }
45 | ///
46 | /// The conversion matrix (3x3)
47 | ///
48 | public override double[] CM
49 | {
50 | get { return new double[] { 0.7161046, 0.1009296, 0.1471858, 0.2581874, 0.7249378, 0.0168748, 0.0, 0.0517813, 0.7734287 }; }
51 | }
52 | ///
53 | /// The inverse conversion matrix (3x3)
54 | ///
55 | public override double[] ICM
56 | {
57 | get { return new double[] { 1.4628067, -0.1840623, -0.2743606, -0.5217933, 1.4472381, 0.0677227, 0.0349342, -0.096893, 1.2884099 }; }
58 | }
59 |
60 | private const double g = 2.19921875d;
61 | private const double g1 = 1 / g;
62 |
63 | private static readonly Whitepoint wp = new WhitepointD50();
64 |
65 | ///
66 | /// Creates a new instance of the class
67 | ///
68 | public Colorspace_WideGamutRGB()
69 | : base(wp)
70 | { }
71 |
72 | ///
73 | /// Linearizes a color
74 | ///
75 | /// Pointer to non-Linear input values
76 | /// Pointer to linear output values
77 | public unsafe override void ToLinear(double* inVal, double* outVal)
78 | {
79 | outVal[0] = Math.Pow(inVal[0], g);
80 | outVal[1] = Math.Pow(inVal[1], g);
81 | outVal[2] = Math.Pow(inVal[2], g);
82 | }
83 |
84 | ///
85 | /// Delinearizes a color
86 | ///
87 | /// Pointer to linear input values
88 | /// Pointer to non-Linear output values
89 | public unsafe override void ToNonLinear(double* inVal, double* outVal)
90 | {
91 | outVal[0] = Math.Pow(inVal[0], g1);
92 | outVal[1] = Math.Pow(inVal[1], g1);
93 | outVal[2] = Math.Pow(inVal[2], g1);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------