Android Question Custom Dialog colorpicker RGB values

saunwin

Active Member
Licensed User
Longtime User
Hello,

I just downloaded this code and created a Custom Dialog colorpicker. Question is
what format is the int ColorResult ? and is there a way of getting the RGB information from this number ?
TIA.

B4X:
Sub btnSelectColor_Click
   Dim cw As ColorWheelDialog
   cw.Initialize
   cw.ShowAsync(Me, "Select Color")
   Wait For (cw) Color_Result(Success As Boolean)
   If Success Then
     Activity.Color = cw.ColorResult
   End If
End Sub
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Which reports -167121129 and other similar numbers, are these ARGB ?
No - it's an int value. If you want to get the ARGB, try this:

B4X:
Private Sub GetARGB(color as Int)
    Private alpha As Int = Bit.UnsignedShiftRight(Bit.And(color, 0xff0000), 24)
    Private red As Int = Bit.UnsignedShiftRight(Bit.And(color, 0xff0000), 16)
    Private green As Int = Bit.UnsignedShiftRight(Bit.And(color, 0xff00), 8)
    Private blue As Int = Bit.And(color, 0xff)
End Sub

- Colin.
 
Upvote 0
Top