diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-07-05 11:26:01 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-07-05 11:26:01 +0300 |
| commit | 3ac0c04e830c7199039979bff44d96a88cd9cc51 (patch) | |
| tree | 018c60565e3414d87bc8309b3382d85b6eb5a076 /Software/Visual_Studio/Tango.BL/ExtensionMethods | |
| parent | 22dd2a3dea15628a9242cb585d615b9b2e4e5422 (diff) | |
| download | Tango-3ac0c04e830c7199039979bff44d96a88cd9cc51.tar.gz Tango-3ac0c04e830c7199039979bff44d96a88cd9cc51.zip | |
Fixed RGB to LAB conversion using Colorful.
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/ExtensionMethods')
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorMineExtensions.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorMineExtensions.cs b/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorMineExtensions.cs new file mode 100644 index 000000000..de8c7f69b --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorMineExtensions.cs @@ -0,0 +1,29 @@ +using ColorMine.ColorSpaces; +using Colourful; +using Colourful.Conversion; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +public static class ColorMineExtensions +{ + public static Rgb ToRgbUsingColorful(this Lab lab) + { + LabColor labColor = new LabColor(lab.L, lab.A, lab.B); + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + var output = converter.ToRGB(labColor); + var color = output.ToColor(); + return new Rgb(color.R, color.G, color.B); + } + + public static Lab ToLabUsingColorful(this Rgb rgb) + { + RGBColor rgbColor = RGBColor.FromRGB8bit((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + var output = converter.ToLab(rgbColor); + return new Lab(output.L, output.a, output.b); + } +} + |
