File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes maintain a BufferedImage as it is......... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "maintain a BufferedImage as it is........." Watch "maintain a BufferedImage as it is........." New topic

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

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
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.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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.


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: maintain a BufferedImage as it is.........
It's not a secret anymore!