aspose file tools*
The moose likes Applets and the fly likes Saving image at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Saving image at runtime" Watch "Saving image at runtime" New topic
Author

Saving image at runtime

padma patil
Ranch Hand

Joined: Nov 06, 2001
Posts: 41
Hi,
I am generating some graph in Applet mainly using drawLine() and drawOval() methods and now wanted to save the graph ( which I can view from appletviewer )as image(.bmp or jpeg format).
I realy don't have clue about this. Does anybody knows?
-
padmashree
David G Risner
Ranch Hand

Joined: May 02, 2002
Posts: 30
First, you should double-buffer your drawing. That is, do all of your drawing into an Image object and then paint that Image.
Second, get the JPEG Encoder from Obrador: http://www.obrador.com/essentialjpeg/jpeg.htm
Third, you can use something like the following method to write the Image as a JPEG to an OutputStream:

Of course, getting permission to create a file from an applet is a whole other can of worms....


David G. Risner<br />Software Engineer<br />California State University, Los Angeles
padma patil
Ranch Hand

Joined: Nov 06, 2001
Posts: 41
Thanks.
I am using JpegEncoder to save image. it works.
I have used policy file to grant File access to Applet.
I have posted another question for "loading policy file from Applet"

Let me know your feedback
-
padmashree
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Saving image at runtime