Results 1 to 2 of 2

Thread: saving an image

  1. #1
    shakeel is offline Member
    Join Date
    Dec 2010
    Posts
    20
    Rep Power
    0

    Default saving an image

    Hi everyone,

    I'm using JFileChooser to save an image, using the showSaveDialog. My problem is that I can't use ImageIO.write as I'm not using buffered image but instead I'm using ImageIcon, stuffed in a label and displayed using JInternalFrame. Is there any other methods to save an ImageIcon other than using ImageIO.write and casting my ImageIcon to RenderedImage like that (RenderedImage)myFrame.getImage() in the ImageIO.write function???

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    I'm using JFileChooser to save an image
    Not possible. JFileChooser doesn't save (nor open) a file. It provides the api to select a file.

    I can't use ImageIO.write as I'm not using buffered image but instead I'm using ImageIcon
    1. ImageIO#write(...) takes a RenderedImage, not a BufferedImage argument.
    2. Get the Image form the ImageIcon and paint it to a newly created BufferedImage of the same size and appropriate type. Than save the BufferedImage.

    casting my ImageIcon to RenderedImage like that (RenderedImage)myFrame.getImage()
    Huh? Don't know what you're trying to express, but you can't cast something to something else that it isn't. You can only cast ImageIcon#getImage(...) to a Buffered image if the image contained in the icon really is a BufferedImage, in which case you would have a reference to the image you used to construct (or setImage) the ImageIcon and wouldn't need to retrieve it from getImage.

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    db

Similar Threads

  1. Error in saving an Image????
    By LankanSniper in forum Java 2D
    Replies: 4
    Last Post: 11-07-2009, 04:48 AM
  2. Saving image to sever.
    By dudejonne in forum New To Java
    Replies: 5
    Last Post: 11-03-2009, 02:01 PM
  3. [SOLVED] Image drawing, saving
    By Goseph in forum Java 2D
    Replies: 2
    Last Post: 12-21-2008, 07:36 PM
  4. Saving Values
    By Sysem in forum New To Java
    Replies: 10
    Last Post: 06-02-2008, 06:29 PM
  5. Replies: 0
    Last Post: 01-08-2008, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •