color recognition

danoptic

Member
Licensed User
Longtime User
is there any example of app or code doing a color recognition. I need to be able to check the back color of an image.
I know that using the AdvancedCanera allow me to get an image but how do I check the color?

Thanks

Dan
 

klaus

Expert
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim 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()
    Dim 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
Beginner's Guide chapter 17.28 Get the Alpha / Red / Green / Blue

Best regards.
 
Upvote 0
Top