Solved

Convert argb values into hsla values in vb access

Posted on 2014-02-07
4
279 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

773 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