私はこれを機能させるために何時間も努力してきましたが、何らかの理由で一致が見つかりません。任意の画像でテストできますが、画面の左上隅のスクリーンショット (1000px x 1000px) を取得し、その中で指定された画像を見つける必要があります。どんな助けでも大歓迎です!
        import java.awt.Rectangle;
        import java.awt.Robot;
        import java.awt.image.BufferedImage;
        import java.io.File;
        import java.io.IOException;
        import javax.imageio.ImageIO;
        public class ImageRobotTester {
            /**
             * @param args
             */
            public static void main(String[] args) {
                ImageRobot i = new ImageRobot();
                try {
                    BufferedImage settingsImage = ImageIO.read(new File("images/Dex.png"));
                    Robot r = new Robot();
                    BufferedImage screen = r.createScreenCapture(new Rectangle(0, 0, 1000, 1000));
                    i.subImage(settingsImage, screen);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
      import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class ImageRobot {
    public ImageRobot() {
        // TODO Auto-generated constructor stub
    }
    public void subImage(BufferedImage needle, BufferedImage hayStack)
    {
        int xMatch = 0;
        int yMatch = 0;
        int possMatches = 0;
        try {
            for(int j = 0; j < hayStack.getHeight() - needle.getHeight(); j++)
            {
                for(int i = 0; i < hayStack.getWidth() - needle.getWidth(); i++)
                {
                    BufferedImage hayStackSub = hayStack.getSubimage(i, j, needle.getWidth(), needle.getHeight());
                    if(hayStackSub.equals(needle))
                    {
                        System.out.println("match!");
                        xMatch = i;
                        yMatch = j;
                    }
                }
            }
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
            System.out.println("Out of bounds! (" + xMatch + ", " + yMatch + ")");
        }
        System.out.println("(" + xMatch + ", " + yMatch + ")");
    }
}