|
Java - Get RGB Values Fom Image Anonymous |
10 year
|
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 [1446 posts] |
10 year
|
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.
STeven.
|
|
|
Anonymous |
10 year
|
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. RRImageAPI.zip
|
|