aspose file tools*
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
Author

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.
Netharam.:confused.
Nathan Pruett
Bartender

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.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: maintain a BufferedImage as it is.........