Android Question Finding a colour on the screen

AlexOfOz

Active Member
Licensed User
Longtime User
Is there a way I can get the colour that is on the screen?
I am showing a photo in an imageview and want to be able to identify the colour at any spot on that photo.

Thanks.
Alex
 

mangojack

Expert
Licensed User
Longtime User
If the image is a Bitmap you could use the Bitmap.GetPixel method.
Place a Transparent Panel over the image and use Touch Event to get the co-ordinates .
Just be sure the panel is resized to match image size.

B4X:
Private Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    GetPixelColour(X, Y)
End Sub

Private Sub GetPixelColour(x As Int, y As Int)
    Dim pixel As Int = bmpTestImage.GetPixel(x, y)
    Label1.Color = pixel
    '............

There is more info availiable ... Search Results


A basic example is attached ...
 

Attachments

  • Test Colour.zip
    35.5 KB · Views: 27
Upvote 0

AlexOfOz

Active Member
Licensed User
Longtime User
If the image is a Bitmap you could use the Bitmap.GetPixel method.
Place a Transparent Panel over the image and use Touch Event to get the co-ordinates .
Just be sure the panel is resized to match image size.

B4X:
Private Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    GetPixelColour(X, Y)
End Sub

Private Sub GetPixelColour(x As Int, y As Int)
    Dim pixel As Int = bmpTestImage.GetPixel(x, y)
    Label1.Color = pixel
    '............

There is more info availiable ... Search Results


A basic example is attached ...
Thank-you very much. I expected there would be a way, and now I know.

Alex
 
Upvote 0
Top