/** * Read the drawable's pixels to TextureData and Texture, if requested at construction, * and returns an aligned {@link BufferedImage}. * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param awtOrientation flips the data vertically if <code>true</code>. * The context's drawable {@link GLDrawable#isGLOriented()} state * is taken into account. * Vertical flipping is propagated to TextureData * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). * @see #AWTGLReadBufferUtil(GLProfile, boolean) */ public BufferedImage readPixelsToBufferedImage(final GL gl, final boolean awtOrientation) { return readPixelsToBufferedImage(gl, 0, 0, 0, 0, awtOrientation); }
private AWTGLReadBufferUtil makeScreenshot(GL gl) { AWTGLReadBufferUtil screenshot = new AWTGLReadBufferUtil(gl.getGLProfile(), true); screenshot.readPixels(gl, true); image = screenshot.getTextureData(); return screenshot; }
/** * Returns the {@link AWTGLPixelBuffer}, as filled by previous call to {@link #readPixels(GL, int, int, int, int, boolean)}. */ public AWTGLPixelBuffer getAWTGLPixelBuffer() { return (AWTGLPixelBuffer)this.getPixelBuffer(); }
/** * Uses a dedicated {@link AWTGLReadBufferUtil} to read a buffered image. * @see {@link getLastScreenshotImage()} to retrieve the image */ @Override public void display(GLAutoDrawable canvas) { GL gl = canvas.getGL(); if (view != null) { view.clear(gl); view.render(gl, glu); if (doScreenshotAtNextDisplay) { AWTGLReadBufferUtil screenshot = new AWTGLReadBufferUtil(GLProfile.getGL2GL3(), true); screenshot.readPixels(gl, true); image = screenshot.getTextureData(); bufferedImage = screenshot.readPixelsToBufferedImage(gl, true); doScreenshotAtNextDisplay = false; } } }
@Override public void display(GLAutoDrawable glAutoDrawable) { if (OTFClientControl.getInstance().getOTFVisConfig().getRenderImages()) { GL2 gl = glAutoDrawable.getGL().getGL2(); if (this.lastShot < hostControlBar.getSimTime()) { this.lastShot = hostControlBar.getSimTime(); try { int screenshotInterval = 1; if (hostControlBar.getSimTime() % screenshotInterval == 0) { AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(gl.getGLProfile(), false); BufferedImage bufferedImage = glReadBufferUtil.readPixelsToBufferedImage(gl, true); ImageIO.write(bufferedImage, "png", new File("frame" + String.format("%07d", hostControlBar.getSimTime()) + ".png")); } } catch (GLException | IOException | IllegalArgumentException e) { e.printStackTrace(); } } } }
height= inHeight; if( readPixelsImpl(drawable, gl, inX, inY, width, height, awtOrientation) ) { final BufferedImage image = getAWTGLPixelBuffer().getAlignedImage(width, height); if( getTextureData().getMustFlipVertically() ) { ImageUtil.flipImageVertically(image);
AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(gl.getGLProfile(), true); this.current = glReadBufferUtil.readPixelsToBufferedImage(gl, false);
protected BufferedImage makeScreenshotAsBufferedImage(GL gl) { AWTGLReadBufferUtil screenshot = makeScreenshot(gl); return screenshot.readPixelsToBufferedImage(gl, true); }