Now it's pretty easy. Libgdx gives an example that can be found here .
I had to add one expression to make it work. Image cannot be saved directly to /screenshot1.png . Just add Gdx.files.getLocalStoragePath() .
Source:
public class ScreenshotFactory { private static int counter = 1; public static void saveScreenshot(){ try{ FileHandle fh; do{ fh = new FileHandle(Gdx.files.getLocalStoragePath() + "screenshot" + counter++ + ".png"); }while (fh.exists()); Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); PixmapIO.writePNG(fh, pixmap); pixmap.dispose(); }catch (Exception e){ } } private static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown){ final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h); if (yDown) {
source share