import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.ByteArrayOutputStream; public class ImageSearch { private int x; private int y; public byte[] byte_array(BufferedImage image) { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { ImageIO.write(image, "png", os); return os.toByteArray(); } catch (Exception e) { return null; } } public void searchImage(BufferedImage img1, BufferedImage img2) { int w = img2.getWidth(); int h = img2.getHeight(); this.x=-1; this.y=-1; int firstpix = img2.getRGB(0, 0); int midpix = img2.getRGB(w/2, h/2); byte[] b2 = this.byte_array(img2); byte[] b1; BufferedImage find; for (int x=0; x