Android Question get the RGB color from getpixel ??

Discussion in 'Android Questions' started by ilan, Jul 30, 2015.

  1. ilan

    ilan Expert Licensed User


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

    klaus Expert Licensed User

    Beginner's Guide chapter 18.28 Get the Alpha / Red / Green / Blue values
    Sub Activity_Create(FirstTime As Boolean)
    Private argb() As Int
        argb = GetARGB(
    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(4As Int
    0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
    1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
    2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
    3) = Bit.And(Color, 0xff)
    Return res
    End Sub
  3. ilan

    ilan Expert Licensed User

    thank you very much klaus :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice