/** * create a new image from a Sikuli ScreenImage (captured)<br> * can only be reused with the object reference * * @param img ScreenImage */ public Image(ScreenImage img) { this(img.getImage(), null); }
public ScreenImage getSub(Rectangle sub) { if (!_roi.contains(sub)) { return this; } BufferedImage img = _img.getSubimage(sub.x - x, sub.y - y, sub.width, sub.height); return new ScreenImage(sub, img); }
/** * creates the PNG tempfile only when needed. * * @return absolute path to stored tempfile * @throws IOException if not found * @deprecated use getFile() instead */ @Deprecated public String getFilename() throws IOException { return getFile(); }
/** * stores the image as PNG file in the given path * with a created filename (sikuliximage-timestamp.png) * * @param path valid path string * @return absolute path to stored file */ public String getFile(String path) { return save(path); }
shot.getFile(path, name); } else { shot.saveInBundle(name);
public void saveLastScreenImage() { ScreenImage simg = getScreen().getLastScreenImageFromScreen(); if (simg != null) { simg.saveLastScreenImage(runTime.fSikulixStore); } } //</editor-fold>
public String saveInBundle(String name) { if (!name.endsWith(".png")) { name += ".png"; } if (!name.startsWith("_")) { name = "_" + name; } File fImage = new File(name); try { fImage = new File(ImagePath.getBundlePath(), name); createFile(fImage); Debug.log(3, "ScreenImage.saveInBundle:\n%s", fImage); } catch (IOException iOException) { Debug.error("ScreenImage.saveInBundle: IOException", iOException); return null; } Image.reload(fImage.getAbsolutePath()); return fImage.getAbsolutePath(); }
public String saveCapture(String name, Region reg) { ScreenImage simg; if (reg == null) { simg = userCapture("Capture for image " + name); } else { simg = capture(reg); } if (simg == null) { return null; } else { return simg.saveInBundle(name); } }
/** * interactive region create with given message: lets the user draw the rectangle using the mouse * * @param message text * @return the region */ public Region selectRegion(final String message) { Debug.log(3, "TRACE: Screen: selectRegion"); ScreenImage sim = userCapture(message); if (sim == null) { return null; } Rectangle r = sim.getROI(); return Region.create((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight()); } //</editor-fold>
Region r = Region.create(img.getLastSeen()); if (this.contains(r)) { Finder f = new Finder(base.getSub(r.getRect()), r); if (Debug.shouldHighlight()) { if (this.scr.getW() > w + 10 && this.scr.getH() > h + 10) {
/** * INTERNAL USE: use getTimedFile() instead * @return absolute path to stored file */ public String getFile() { if (_filename == null) { _filename = save(); } return _filename; }
/** * create a ScreenImage with given rectangle on this screen. * * @param rect The Rectangle to be captured * @return the image of the region */ @Override public ScreenImage capture(Rectangle rect) { lastCaptureTime = new Date().getTime(); ScreenImage simg = robot.captureScreen(rect); if (Settings.FindProfiling) { Debug.logp("[FindProfiling] Screen.capture [%d x %d]: %d msec", rect.width, rect.height, new Date().getTime() - lastCaptureTime); } lastScreenImage = simg; if (Debug.getDebugLevel() > lvl) { simg.saveLastScreenImage(runTime.fSikulixStore); } return simg; }
/** * stores the image as PNG file in the given path * with the given filename * * @param path valid path string * @param name filename (.png is added if not present) * @return absolute path to stored file */ public String getFile(String path, String name) { if (name == null) { name = Settings.getTimestamp() + ".png"; } else if (!name.endsWith(".png")) { name += ".png"; } try { File tmp = new File(path, name); createFile(tmp); Debug.log(3, "ScreenImage.getFile:\n%s", tmp); } catch (IOException iOException) { Debug.error("ScreenImage.getFile: IOException", iOException); return null; } return _filename; }
/** * create a new image from a Sikuli ScreenImage (captured)<br> * giving it a descriptive name for printout and logging <br> * can only be reused with the object reference * * @param img ScreenImage * @param name descriptive name */ public Image(ScreenImage img, String name) { this(img.getImage(), name); }
public String saveScreenCapture() { return getScreen().capture(this).save(); }
@Override public ScreenImage capture(int x, int y, int w, int h) { BufferedImage image = client.getFrameBuffer(x, y, w, h); ScreenImage img = new ScreenImage( new Rectangle(x, y, w, h), image ); lastScreenImage = img; return img; }
/** * stores the lastScreenImage in the given path with the given name * * @param path path to use * @param name file name (.png is added if not there) * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile(String path, String name) throws IOException { return getScreen().getLastScreenImageFromScreen().getFile(path, name); }
public static void screenClipUser() throws IOException{ org.sikuli.script.Screen screen = Screen.getPrimaryScreen(); org.sikuli.script.Region region = screen.selectRegion("Select Area to capture as Image"); ScreenImage clip = region.getLastScreenImage(); // screen.userCapture(); ScreenImage printScreen = region.getScreen().capture(); javax.imageio.ImageIO.write(clip.getImage(), "PNG", new File("D:\\SikuliImages\\Clip.png")); ImageIO.write(printScreen.getImage(), "PNG", new File("D:\\SikuliImages\\PrintScreen.png")); screenCaptureRegion(screen); } public static void screenCaptureRegion(Screen screen) throws IOException{ java.awt.Point point = MouseInfo.getPointerInfo().getLocation(); System.out.println("Mouse Location Co-Ordinates Previous Selected : " + point); //ScreenImage capturedRegion = screen.capture(point.x, point.y, 200, 200); ScreenImage capturedRegion = screen.capture(clip.x, clip.y, clip.w, clip.h); ImageIO.write(capturedRegion.getImage(), "PNG", new File("D:\\SikuliImages\\CapturedRegion.png")); }
public String saveScreenCapture(String path, String name) { return getScreen().capture(this).save(path, name); }
public ScreenImage captureScreen(Rectangle rect) { BufferedImage bimg = captureDeviceScreen(rect.x, rect.y, rect.width, rect.height); return new ScreenImage(rect, bimg); }