Java - Get RGB Values Fom Image
4 years
I'm currently using the Java API and I am trying to read the face of a Rubik's cube. I use the image below and re-size it to a 3x3 image.

I have tried many methods of getting the RGB values of the pixels. I am trying to use a BufferedImage but all of the pixels are black. What is the correct way to retrieve these values?

Steven Gentner from United States  [1370 posts] 4 years
You should be able to use the getImage API function to get the image from RoboRealm into Java. I'm not sure where you are using the BufferedImage class. Perhaps you can post more of your code?

Alternatively, since you are working with such a small image you can also create variables for each pixel which you could access using the GetVariable API ... if that's easier.

Anonymous 4 years
I ended up getting it working. I used bitwise operators to parse the byte array manually and stored the values I wanted accordingly.

For anyone who wants it, the API sources are attached below, just initialize it with:

RRImage rrimage = new RRImage(<image from API>, <image height>, <image width>);

The getPixel(row, column) function returns the desired pixel.
It uses the same index method as you would with a matrix.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index