How does Robot's getPixelColor(int x, int y) method work?

后端 未结 1 1850
栀梦
栀梦 2020-12-06 22:15

How exactly does the method getPixelColor(int x,int y) from the Robot class work? I tried this code fragment:

try 
{
     Robot robos = new Robot();
}
cat         


        
相关标签:
1条回答
  • 2020-12-06 22:38

    how can i solve this problem?

    Don't use the Robot to get the colors pixel by pixel. Use the Robot the create a BufferedImage of the screen. Then you can use the getRGB() method of the BufferedImage to get the int value that represents the color of the pixel. You can then create a Color Object using this int or parse out the red/green/blue values directly.

    0 讨论(0)
提交回复
热议问题