i am trying to save an image that i have in a JLabel as a jpeg file. i am able to load the image as an ImageIcon and then add it to a label but when i try to save it using ImageIO.write() it just turns the whole thing black. would someone please be able to tell me wat im doing wrong.
thanks
try{
//open file dialog box Frame frame = new Frame(); FileDialog fd = new FileDialog(frame, "Save File", FileDialog.SAVE); fd.show();
//retirve the path path = fd.getDirectory();
//retrieve the filename filename = fd.getFile();
//add the filename and path together filename = path + filename;
BufferedImage bi = new BufferedImage(im.getIconWidth(),im.getIconHeight(),BufferedImage.TYPE_INT_RGB);
ImageIO.write((RenderedImage)bi, "jpeg", new File(filename));
} catch(IOException e) { // Print out the exception that occurred System.out.println("Unable to Save"); }