DR00ME Posted February 24, 2004 Posted February 24, 2004 Does Anyone know a better algorithm for changing HSV values to RGB ? Public Shared Sub ConvertHSBToRGB(h As Single, s As Single, v As Single, ByRef r As Single, ByRef g As Single, ByRef b As Single) If s = 0F Then ' if s = 0 then h is undefined r = v g = v b = v Else Dim hue As Single = System.Convert.ToSingle(h) If h = 360F Then hue = 0F End If hue /= 60F Dim i As Integer = Fix(Math.Floor(System.Convert.ToDouble(hue))) Dim f As Single = hue - i Dim p As Single = v *(1F - s) Dim q As Single = v *(1F - s * f) Dim t As Single = v *(1F - s *(1 - f)) Select Case i Case 0 r = v g = t b = p Case 1 r = q g = v b = p Case 2 r = p g = v b = t Case 3 r = p g = q b = v Case 4 r = t g = p b = v Case 5 r = v g = p b = q Case Else r = 0F g = 0F b = 0F 'Trace.Assert(false); ' hue out of range End Select End If End Sub 'ConvertHSBToRGB Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
DR00ME Posted February 24, 2004 Author Posted February 24, 2004 (edited) OMG: WINDOWS API Function "ColorHLSToRGB" from "Shlwapi.dll" I think Im gonna dance now tough it is 4:20 am....:D Private Declare Function ColorHLSToRGB Lib "SHLWAPI.DLL" _ (ByVal wHue As Integer, ByVal wLuminance As Integer, ByVal wSaturation As Integer) As Long How do I convert this Long to RGB ? I got some weird readings like 567345235234...erm HELP! Edited February 24, 2004 by DR00ME Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.