mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Fixed wrong hsv to rgb calculation
This commit is contained in:
parent
cf1ebb1a1c
commit
17beace550
@ -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));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user