Saving Image object to disk
hello guys,
i have this trouble in writing image object to disk. i am having an applet where i have declared an image object , i draw a figure in this image, so far so good. then i have created a button 'save to disk' which calls the method saveImage() upon being clicked. this method is required to save image object (of size around 800 X 600) to disk as jpeg file, how do i go about doing it?
here's the parts of code that are in connection with this problem:
publicclass man7extends Appletimplements ActionListener,MouseListener,MouseMotionListener{
.
.
.
Image img;
Graphics imgGraphics;
. . .
publicvoid actionPerformed(ActionEvent evt){
if(evt.getSource()==draw){// drawing the image for first time
.
.
img = createImage(xSize, ySize);
imgGraphics = img.getGraphics();
drawMyImage();
.
.
}
if(evt.getSource()==save){
saveImage();
showStstus("saved");
}
}
publicvoid update(Graphics g){
g.drawImage(img, 0, 0,this);// update() called many times as per user's actions
.
.
}
void drawMyImage(){
..
for( .. )//some loops to draw each pixel
imgGraphics.drawLine(x,y,x,y);
..
}
public saveImage(){
/*
here's where i need help, to write the object img to disk as a jpeg file
*/
}
}// end of class man7
i have tried many stuff none of which worked so i have not posted any (unsuccessful ) code in saveImage() method
please help,
thanks in advance
Ishwar

