/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; try { fire = ParticleIO.loadConfiguredSystem("testdata/system.xml"); } catch (IOException e) { throw new SlickException("Failed to load particle systems", e); } copy = new Image(400,300); String[] formats = ImageOut.getSupportedFormats(); message = "Formats supported: "; for (int i=0;i<formats.length;i++) { message += formats[i]; if (i < formats.length - 1) { message += ","; } } }
public static void takeScreenshot(GameContainer container) { try { File FileSSDir = new File("screenshots"); if (!FileSSDir.exists()) { FileSSDir.mkdirs(); } int number = 0; String screenShotFileName = "C:" + File.separator + "screenshotsgppcc7" + File.separator + number + ".png"; File screenShot = new File(screenShotFileName); while (screenShot.exists()) { number++; screenShotFileName = "C:" + File.separator + "screenshotsgppcc7" + File.separator + number + ".png"; screenShot = new File(screenShotFileName); } screenBuffer = new Image(container.getWidth(), container.getHeight()); Graphics g = container.getGraphics(); g.copyArea(screenBuffer, 0, 0); ImageOut.write(screenBuffer, screenShotFileName); } catch (Exception e) { e.printStackTrace(); } }
/** * Capture and save to the specified file name * * @param fname The name of the file to write to * @throws SlickException Indicates a failure to capture or write */ private void writeTo(String fname) throws SlickException { g.copyArea(copy, 200,0); ImageOut.write(copy, fname); message = "Written "+fname; }