color button to rgb
Posted
#1
(In Topic #1002)
Enthusiast

Posted
Guru

I do not know the best way.
Here's a function that returns [r,g,b,a] values from a color
It uses Color.ToHTML() to get a Hex value then converts it.
(EDIT: updated to handle alpha)
Code (gambas)
or if you just want the hex value use
Code (gambas)
Prints…
#FF0000
or if handling alpha too.
Code (gambas)
rgba(255,255,0,0.6)
Posted
Regular

Posted
Guru

Cedron said
ooh nice , much better
so with alpha..
Posted
Regular

Posted
Enthusiast

Code
Public Function GetRGB(ArgColor As Integer) As String
Dim r, g, b As Integer
Dim RGB As String
r = Shr(ArgColor, 16) And &FF&
g = Shr(ArgColor, 8) And &FF&
b = ArgColor And &FF&
RGB = Right("0" & Hex(r), 2) & Right("0" & Hex(g), 2) & Right("0" & Hex(b), 2)
Return RGB
End
1 guest and 0 members have just viewed this.


