Solved

Convert argb values into hsla values in vb access

Posted on 2014-02-07
4
285 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
ID: 39843763
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
ID: 39843768
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
ID: 39844391
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
ID: 39861532
thx
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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