有什么简单的方法可以做到呢?谢谢!

解决方案 »

  1.   

    ImageIO.write(RenderedImage im, String formatName, File output);
      

  2.   

    这个方法不行啊!RenderedImage im  这个参数可以传递BufferedImage 对象,但是它并不是如何由Image对象转换为BufferedImage呢
      

  3.   

    不知道,learning.....
    up..up.....
      

  4.   

    java.lang.Object
      |
      +--java.awt.Image
            |
            +--java.awt.image.BufferedImage
      

  5.   

    ImageIO.write(RenderedImage im, String formatName, File output);
      

  6.   

    to  homesos(熊猫贩子) :虽然Image的子类是BufferedImage,但是Image本身并没有实现RenderImage接口啊?
      

  7.   

    唉,偶也不懂,看了一下文档,也没看明白……
    它是这样写滴:
    -----------------------------------------
    Writing Image I/O Applications 
    3.1 Reading and Writing Images 
    The javax.imageio.ImageIO class provides a set of static convenience methods that perform most simple Image I/O operations.
    Reading an image that is in a standard format (GIF, PNG, or JPEG) is simple:
    File f = new File("c:\images\myimage.gif");
    BufferedImage bi = ImageIO.read(f);The format of the image will be auto-detected by the API based on the contents of the file. Most image files contain a "magic number" in their first few bytes that identifies the file format. For formats that do not have a magic number, auto-detection may fail and somewhat more sophisticated application code will be needed.
    Additional formats may be handled by installing JAR files containing plug-ins; the details are described in the next chapter. Once a plug-in has been installed, a new format will be understood automatically without any changes to the application code.The set of formats available for reading can be obtained by calling ImageIO.getReaderFormatNames. This will return an array of Strings containing the names of the available formats, such as "gif" and "png."Writing an image in a supported format is equally simple:
    BufferedImage bi;
    File f = new File("c:\images\myimage.png");
    ImageIO.write(im, "png", f);The list of supported formats may be obtained by calling ImageIO.getWriterFormatNames.
      

  8.   

    最后这段
    ---------------------------
    BufferedImage bi;
    File f = new File("c:\images\myimage.png");
    ImageIO.write(im, "png", f);
    ---------------------------
    还是没看明白,咋整,郁闷
      

  9.   

    用BufferedImage来存储图像,这个并不难!
    最后这段
    ---------------------------
    BufferedImage bi;//这里还没有初始化,应该给起赋值
    File f = new File("c:\images\myimage.png");
    ImageIO.write(im, "png", f);//im应该改成bi吧
    总的意思是将bi中的数据以png的格式存储在f文件中