Solved

Convert argb values into hsla values in vb access

Posted on 2014-02-07
4
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

751 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