[Solved] Getting RGB at a texture coordinate

I found this post:


however, it is old and does not integrate with JME2.

Basically, I am looking for a quick way to grab the RGB out of my image at specific texture coordinates.

Does anyone know of a way to do this inside JME2?

Thank you.


see here


for example, since I am using a black and white .jpg, the rgb values are == v value

so I can determine probability off of the darkness (the darker, the less probability)

   public float getGalacticProbability(Vector2f picker){

      URL url = TestGetTextureCoordinate.class.getResource("galaxy.jpg");

      BufferedImage image = null;
      try {
         image = ImageIO.read(url);
      } catch (IOException e) {
         // TODO Auto-generated catch block
         // Getting pixel color by position
       int clr=  image.getRGB((int)picker.x,(int)picker.y);
       int  red   = (clr & 0x00ff0000) >> 16;
       System.out.println("Red Color value = "+ red+"  Prob:"+((float)red)/255);
      return red/255;