码迷,mamicode.com
首页 > 编程语言 > 详细

Java 图片读取与存储

时间:2014-08-12 03:07:23      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   java   io   div   new   log   

 1  @Override
 2     public Image myWrite(Image image, String filePath) throws IOException {
 3         if (image == null) {
 4             throw new IOException("Image is null!");
 5         }
 6 
 7         // create a file
 8         File imgFile = new File(filePath + ".bmp");
 9         BufferedImage bmp = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
10         Graphics2D graph = bmp.createGraphics();
11 
12         // call the Graphics drawImage method
13         graph.drawImage(image, 0, 0, null);
14 
15         // write to this file
16         ImageIO.write(bmp, "bmp", imgFile);
17         // read file
18         BufferedImage readbmp = ImageIO.read(imgFile);
19         return readbmp;
20     }

 

Java 图片读取与存储,布布扣,bubuko.com

Java 图片读取与存储

标签:style   blog   color   java   io   div   new   log   

原文地址:http://www.cnblogs.com/xulf/p/3906181.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!