to homesos(熊猫贩子) :虽然Image的子类是BufferedImage,但是Image本身并没有实现RenderImage接口啊?
唉,偶也不懂,看了一下文档,也没看明白…… 它是这样写滴: ----------------------------------------- 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.
最后这段 --------------------------- BufferedImage bi; File f = new File("c:\images\myimage.png"); ImageIO.write(im, "png", f); --------------------------- 还是没看明白,咋整,郁闷
用BufferedImage来存储图像,这个并不难! 最后这段 --------------------------- BufferedImage bi;//这里还没有初始化,应该给起赋值 File f = new File("c:\images\myimage.png"); ImageIO.write(im, "png", f);//im应该改成bi吧 总的意思是将bi中的数据以png的格式存储在f文件中
up..up.....
|
+--java.awt.Image
|
+--java.awt.image.BufferedImage
它是这样写滴:
-----------------------------------------
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.
---------------------------
BufferedImage bi;
File f = new File("c:\images\myimage.png");
ImageIO.write(im, "png", f);
---------------------------
还是没看明白,咋整,郁闷
最后这段
---------------------------
BufferedImage bi;//这里还没有初始化,应该给起赋值
File f = new File("c:\images\myimage.png");
ImageIO.write(im, "png", f);//im应该改成bi吧
总的意思是将bi中的数据以png的格式存储在f文件中