有什么简单的方法可以做到呢?谢谢!
解决方案 »
- 如果java程序超过了jvm设置的最大堆大小会如何工作?
- linux下运行jar文件报错未找到资源文件
- 需求分析文档
- 急!!求正则表达式,最常用的数据格式验证
- applet程序加载失败,求助!~~
- SOS:java函数定时问题
- 这是怎么回事,JB的问题?
- 怎么检查文件"c:\temp.txt是否存在,如果不存在怎么创建?
- 一个有关GUI界面的问题,求高手帮忙解答 感激不尽
- 求教关于Java读取.Dat的数据文件的问题,先拜谢
- log4j的疑惑:如果我在两个java源代码文件里面使用Logger,该怎么用呢?网上的例子都是针对一个源代码文件的。
- Java Applet能否用JAI来读写、显示BMP格式的图像?
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文件中