Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create an image from JPanel contents?  RSS feed

 
Aran Winters
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to generate an image (BufferedImage) from the contents of a JPanel. The JPanel is being used much as a canvas in a paint program. I think I am on the right path by trying to create a BufferedImage, and then writing it using ImageIO.write() or something similar. The image type if flexible though so I am willing to limit output to JPEGs. My problem is that I am not able to see how to get to a BufferedImage object from any JComponent methods.

Thanks,

\Aran.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the codes in this post should do what you want

http://forum.java.sun.com/thread.jspa?threadID=604040
 
Aran Winters
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many Thanks,

I was able to pull out the relevent code and do what I wanted.

/Aran.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!