简体   繁体   中英

How to get pixel color of an image without BufferedImage?

I am making a maze game where your mouse can't touch a certain color. The problem I am having is getting the pixel color without using a BufferedImage. Are there any alternatives?

Not tested. Try to use Robot and PointerInfo declared as:

PointerInfo pointer = MouseInfo.getPointerInfo();
Point coord = pointer.getLocation();
Robot robot = new Robot();

And then to get a Color upon a Point :

Color color = robot.getPixelColor((int)coord.getX(), (int)coord.getY());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM