# Convert argb values into hsla values in vb access

I have a file of argb values in a table and would like to convert them to hsla values, not sure how to write the function for that. I am in access 13
###### Who is Participating?

Commented:
The function you have above should suffice.  The Alpha value for the opacity channel stays the same when converted from argb (or rgba) to hsla.

So an argb value of (.85, 255, 0, 0) will convert to an hsla value of (0, 100%, 50%, .85).  In both color models the alpha transparency remains at .85.

Ron
0

Author Commented:
I did a little research and found this:

stackoverflow.com/questions/12373699/converting-rgba-hsl-and-hsla-colors-to-rgb-or-in-a-java-awt-color-object

I am not familiar with the method used
0

Author Commented:
I also found this but it doesnt deal with hsla

One other way if its possible would be to extract the hsla values direct from the image file.
The only program I found only extracts rgba.

``````' Convert an RGB value into an HLS value.
Private Sub RgbToHls(ByVal R As Double, ByVal G As Double, _
ByVal B As Double, ByRef H As Double, ByRef L As _
Double, ByRef S As Double)
Dim max As Double
Dim min As Double
Dim diff As Double
Dim r_dist As Double
Dim g_dist As Double
Dim b_dist As Double

' Get the maximum and minimum RGB components.
max = R
If max < G Then max = G
If max < B Then max = B

min = R
If min > G Then min = G
If min > B Then min = B

diff = max - min
L = (max + min) / 2
If Abs(diff) < 0.00001 Then
S = 0
H = 0   ' H is really undefined.
Else
If L <= 0.5 Then
S = diff / (max + min)
Else
S = diff / (2 - max - min)
End If

r_dist = (max - R) / diff
g_dist = (max - G) / diff
b_dist = (max - B) / diff

If R = max Then
H = b_dist - g_dist
ElseIf G = max Then
H = 2 + r_dist - b_dist
Else
H = 4 + g_dist - r_dist
End If

H = H * 60
If H < 0 Then H = H + 360
End If
End Sub
``````
0

Author Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.