How to get the color of the image pixel on which I clicked?

I don’t know if you are still looking for a solution.

I just made this prototype for you… hope is clear enough.

Here’s a video of the result.

By the way, the image library has plenty of methods to workaround what you need… in case you need it, and pixel values are accessible as List, so you can workaround the KML colors and treat the list as a grid (rows, cols math to find the index).

Warning: the library uses a different color format (#AABBGGRR), but can be converted easily though.

UPDATE:

I made a v2 based on the limitations noted in the comments, but change the original snippet to show both approaches.
This one generates a snapshot of whatever widget you want (so it takes transforms/colorization/box fittings/whatever u have rendered on screen).

Gives you a lot of versatility, if you don’t have to animate or invalidate the widget often.

Check the demo in youtube.

Leave a Comment