Solved

Convert argb values into hsla values in vb access

Posted on 2014-02-07
4
270 Views
Last Modified: 2014-02-15
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
0
Comment
Question by:PeterBaileyUk
  • 3
4 Comments
 

Author Comment

by:PeterBaileyUk
Comment Utility
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 Comment

by:PeterBaileyUk
Comment Utility
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

Open in new window

0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
Comment Utility
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 Closing Comment

by:PeterBaileyUk
Comment Utility
thx
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now