日期:2014-05-20 浏览次数:20992 次
import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; /** * 读取图片 * @author Administrator * */ public class MyBufferedImage { private BufferedImage image = new BufferedImage(256, 256, BufferedImage.TYPE_3BYTE_BGR); public MyBufferedImage(){ File file = new File("images/img.bmp"); if(!file.exists()) return; try { BufferedImage imageRead = ImageIO.read(file); Graphics g = image.getGraphics(); g.drawImage(imageRead, 0, 0, imageRead.getWidth(),imageRead.getHeight(), null); } catch (IOException e) { e.printStackTrace(); } } public BufferedImage getImage(){ return this.image; } }