From 17beace550b0f1bbc31a481154b8229890f1a671 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 24 Dec 2017 12:23:48 +0100 Subject: [PATCH] Fixed wrong hsv to rgb calculation --- RGB.NET.Core/Leds/Color.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Core/Leds/Color.cs b/RGB.NET.Core/Leds/Color.cs index f67a4d8..c638e00 100644 --- a/RGB.NET.Core/Leds/Color.cs +++ b/RGB.NET.Core/Leds/Color.cs @@ -219,13 +219,15 @@ namespace RGB.NET.Core private static (double h, double s, double v) CaclulateHSVFromRGB(byte r, byte g, byte b) { - if ((r == g) && (g == b)) return (0, 0, 0); + if ((r == g) && (g == b)) return (0, 0, r / 255.0); int min = Math.Min(Math.Min(r, g), b); int max = Math.Max(Math.Max(r, g), b); double hue; - if (max == r) // r is max + if (max == min) + hue = 0; + else if (max == r) // r is max hue = (g - b) / (double)(max - min); else if (max == g) // g is max hue = 2.0 + ((b - r) / (double)(max - min));