Android Question get the RGB color from getpixel ??

ilan

Expert
Licensed User
Longtime User
hi

how do i convert the color int i get with bmp.getpixel to an rgb color or html color string??
 

klaus

Expert
Licensed User
Longtime User
Beginner's Guide chapter 18.28 Get the Alpha / Red / Green / Blue values
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Private argb() As Int
    argb = GetARGB(Colors.Transparent)
    Log("A = " & argb(0))
    Log("R = " & argb(1))
    Log("G = " & argb(2))
    Log("B = " & argb(3))
End Sub

Sub GetARGB(Color As Int) As Int()
    Private res(4) As Int
    res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
    res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
    res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
    res(3) = Bit.And(Color, 0xff)
    Return res
End Sub
 
Upvote 0
Top