Skip to content
Advertisement

getRGB throws error when trying to get the color of coordinates of an image

I have been searching for ways to get the color of a coordinate (x, y) of an image.

I have an image, Image depthImage = mActivityTestRule.getActivity().getDepthImage();, and I would like to do that, by giving the coordinates.

My project is an ARCore project (git clone https://github.com/google-ar/arcore-android-sdk.git)

One solution that I found is

JavaScript

but the expression getRGB is highlighted in red. There are not any suggested solutions by Android Studio. I tried importing BufferedImage using java.awt.image.BufferedImage to use it, but it was not possible even to import it.

I have also found a solution that would look like this:

JavaScript

But the same thing happens. getRGB is not recognized properly.

Do you have any way to deal with this?

Additional information:

These are my imports:

JavaScript

And this is my build.gradle(:app):

JavaScript

Advertisement

Answer

I have finally solved it, thanks to these answers: How to convert android.media.Image to bitmap object? and How do you get the RGB values from a Bitmap on Android?

According to How to convert android.media.Image to bitmap object?,

JavaScript

And according to How do you get the RGB values from a Bitmap on Android?,

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement