/** * A Pattern from a BufferedImage * * @param bimg BufferedImage */ public Pattern(BufferedImage bimg) { image = new Image(bimg); }
/** * ONLY FOR INTERNAL USE! Might vanish without notice! * * @param bimg BufferedImage * @return the Pattern object itself */ public Pattern setBImage(BufferedImage bimg) { image = new Image(bimg); return this; }
/** * A Pattern from a ScreenImage * * @param simg ScreenImage */ public Pattern(ScreenImage simg) { image = new Image(simg.getImage()); }
/** * create a sub image from this image * * @param x pixel column * @param y pixel row * @param w width * @param h height * @return the new image */ public Image getSub(int x, int y, int w, int h) { BufferedImage bi = createBufferedImage(w, h); Graphics2D g = bi.createGraphics(); g.drawImage(get().getSubimage(x, y, w, h), 0, 0, null); g.dispose(); return new Image(bi); }
/** * create a new image from the given url <br> * file ending .png is added if missing <br> * filename: ...url-path.../name[.png] is loaded from the url and and cached * <br> * already loaded image with same url is reused (reference) and taken from * cache * * @param url image file URL * @return the image */ public static Image create(URL url) { Image img = get(url); if (img == null) { img = new Image(url); } return createImageValidate(img, true); }
private static void basicTest(ADBScreen adbs) throws FindFailed { log(lvl, "**************** running basic test"); adbs.aSwipeLeft(); adbs.aSwipeRight(); adbs.wait(1f); ScreenImage sIMg = adbs.userCapture("Android"); sIMg.save(RunTime.get().fSikulixStore.getAbsolutePath(), "android"); adbs.aTap(new Image(sIMg)); }
private static Image createImageValidate(Image img, boolean verbose) { if (img == null) { log(-1, "Image not valid, creating empty Image"); return new Image("", null); } if (!img.isValid()) { if (Settings.OcrTextSearch) { img.setIsText(true); if (Settings.isValidImageFilename(img.getName())) { img.setIsText(false); } } else { if (verbose) { log(-1, "Image not valid, but TextSearch is switched off!"); } } } return img; }
sIMg.save(RunTime.get().fSikulixStore.getAbsolutePath(), "android"); try { aScr.aTap(new Image(sIMg)); Sikulix.popup("The image was found on the device's current screen" + "\nand should have been tapped.\n" +
private Image copy() { Image imgTarget = new Image(); imgTarget.setImageName(imageName); imgTarget.setFileURL(fileURL); imgTarget.setBimg(bimg); imgTarget.setGroup(group); imgTarget.setIsAbsolute(imageIsAbsolute); imgTarget.setIsText(imageIsText); imgTarget.setIsBundled(imageIsBundled); imgTarget.setLastSeen(getLastSeen(), getLastSeenScore()); imgTarget.setHasIOException(hasIOException()); if (isPattern()) { imgTarget.setSimilarity(similarity); imgTarget.setOffset(offset); imgTarget.setWaitAfter(waitAfter); imgTarget.setIsPattern(true); } return imgTarget; }
private static boolean doTestSetup(String testSetupSource, boolean silent) { Region r = Region.create(0, 0, 100, 100); Image img = new Image(r.getScreen().capture(r).getImage()); Pattern p = new Pattern(img); Finder f = new Finder(img);