This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maintain a BufferedImage as it is.........

 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI, I want to save a buffered Image as an object to a file ,later convert it to a jpeg or gif
file on the user's request.There is an advantage in this method since the user can't view the
file directly since it is saved as a buffered image.I also want to display this image in my
JFrame,how can it be done?Please reply as soon as possible,awaiting your precious reply Nate.
Happy middling with java.
Netharam.:confused.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how you would save a buffered image to a file without setting the filetype... it would probably be better to save it as some default file type and convert it if the user requested. ( Besides, to save a BufferedImage object, you'd have to subclass it to implement Serializable, and write all the pixel values out to a file or something... believe me... getting it to save as a default file type is easier... )

To display your Buffered Image to the screen is easy... just put it in an ImageIcon, put that ImageIcon on a JLabel, and put the JLabel on a JFrame... here's the code...


If you wanted to display a saved image file you could just put the image file's filename in the ImageIcon constructor instead.

-Nate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic