Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean isOnScreen(BufferedImage bi, int x1, int x2, int y1, int y2) throws AWTException {
- BufferedImage fullScreen = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
- if (fullScreen != null) {
- for (int x = x1; x < x2; x++) {
- for (int y = y1; y < y2; y++) {
- boolean invalid = false;
- int k = x, l;
- for (int a = 0; a < bi.getWidth(); a++) {
- l = y;
- for (int b = 0; b < bi.getHeight(); b++) {
- if (bi.getRGB(a, b) != fullScreen.getRGB(k, l)) {
- invalid = true;
- break;
- } else {
- l++;
- }
- }
- if (invalid) {
- break;
- } else {
- k++;
- }
- }
- if (!invalid) {
- if (!saved) {
- saveCoords(x, y);
- saved = true;
- }
- return true;
- }
- }
- }
- }
- return false; //If no image is found
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement