Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

Using it with BufferedImage #26

Open
rmafort opened this issue Sep 4, 2014 · 2 comments
Open

Using it with BufferedImage #26

rmafort opened this issue Sep 4, 2014 · 2 comments

Comments

@rmafort
Copy link

rmafort commented Sep 4, 2014

Hello, I have an application which works with BufferedImage, adding "layers" and then obtaining the final image using the following code:

BufferedImage buffer; // Current image
Graphics2D g2d = buffer.createGraphics() // Get a Graphics2D to work on this image

And then I work on it adding layers, and then dispose the Graphics2D. I do so on each layer, until I get the final image.

Is there a way to I have use the benefits from GLG2D? Since I can't even cast the Graphics2D obtained to yours GLGraphics2D. Or there is another way to work with images that I don't know yet? Thanks in advance!

@brandonborkholder
Copy link
Owner

You need to draw your scene into a GLPBuffer or an FBO, some offscreen
drawable. Then use the JOGL com.sun.opengl.util.Screenshot class to dump
the FBO to a BufferedImage.

@cmadsen
Copy link

cmadsen commented Jan 13, 2021

Is it possible to get an example of how to do the equivalent of:

		GraphicsEnvironment ge = GraphicsEnvironment
				.getLocalGraphicsEnvironment();
		GraphicsConfiguration gc = ge.getDefaultScreenDevice()
				.getDefaultConfiguration();
		BufferedImage image = gc.createCompatibleImage(200,
				200, Transparency.BITMASK);
                Graphics2D g = image.createGraphics();
                g.fillRect(10, 10, 100, 100);

with glg2d, i.e., so g in the above code becomes a GLGraphics2D?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants