Saving a an image written to a graphics context to a jpeg

R

Rhino

anybody got some code on how to do this? I'm no graphics master.
I don't know how to do it myself but I'm certain this has been asked - and
answered - on one of the comp.lang.java.* newsgroups in the past, probably
this one.

Do a Google Groups search and you should be able to find it easily enough.
 
T

Thomas Weidenfeller

anybody got some code on how to do this? I'm no graphics master.

As has been discussed here many times, you can't in a general way. You
need to know the entity behind the Graphics context (where the
Graphics[2D] object came from). That entity might buffer, and it might
provide methods to fetch that buffer. But there is no guarantee.

/Thomas
 
K

Knute Johnson

anybody got some code on how to do this? I'm no graphics master.

One simple way is to create a BufferedImage, get a Graphics from it and
pass it to the drawing method. Then save the BufferedImage to a file.
Of course this assumes that your drawing method doesn't do a bunch of
other stuff that will mess this up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top