Formula needed for Correct Hue in RGB->HSB.
I've answered my original question up to one point; the hue value. I'm using this formula converted from this page: http://www.cs.rit.edu/~ncs/color/t_convert.html to convert it. Here's my attempt to translate it into VB:
VB Code:
Function RGBtoHSB(R As Single, G As Single, B As Single, H As Long, S As Single, V As Single)
Dim Mini As Single, Maxi As Single, Delta As Single
Mini = Min(R, G, B)
Maxi = Max(R, G, B)
V = Maxi
Delta = Maxi - Mini
If Maxi <> 0 Then
S = Delta / Maxi
Else
S = 0
H = -1
Exit Function
End If
If R = Maxi Then
H = (G - B) / Delta
ElseIf G = Maxi Then
H = 2 + (B - R) / Delta
Else
H = 4 + (R - G) / Delta
End If
H = H * 60
If H < 0 Then H = H + 360
End Function
Function Max(R As Single, G As Single, B As Single) As Single
If R > G Then
If R > B Then
Max = R
Else
Max = B
End If
Else
If G > B Then
Max = G
Else
Max = B
End If
End If
End Function
Function Min(R As Single, G As Single, B As Single) As Single
If R < G Then
If R < B Then
Min = R
Else
Min = B
End If
Else
If G < B Then
Min = G
Else
Min = B
End If
End If
End Function
I'm assuming that's how the Max and Min functions should be, but that's where my problem may lie.