示例#1
0
 private void screenshot(String path, int width, int height) {
   File file = new File(path + "image" + String.format("%04d", filecount) + ".png");
   try {
     //        context.makeCurrent();
     Screenshot.writeToFile(file, width, height);
   } // end of try
   catch (IOException ex) {
     System.out.println(ex);
   } // end of try-catch
   filecount++;
 }
示例#2
0
  private void takeScreenshot(String fileName) {
    BufferedImage ss = Screenshot.readToBufferedImage(0, 0, screen.w, screen.h, false);
    File ssFile = new File(fileName);
    File ssDir = new File("screenshots");
    try {
      if (!ssDir.exists()) ssDir.mkdir();
      ImageIO.write(ss, "png", ssFile);
    } catch (IOException e) {
      e.printStackTrace();
    }

    System.out.println("Screenshot taken: " + ssFile.getAbsolutePath());
  }