1.处理位图
Graphics提供了drawImage方法用于绘制位图
使用步骤:
①.创建Image的子类对象BufferedImage(int width,int height,int ImageTpye)
②.调用BufferedImage对象的getGraphics()方法获取画笔
③.调用组件paint()方法中提供的Graphics对象的drawImage()方法一次性的内存中的图片BufferedImage绘制到特定的组件上
好处:先绘制到内存中的BufferedImage上,等全部绘制完毕后,再一次性显示到组件上
2.ImageIO的使用
对Image读写的操作
方法名称 | 功能 |
static BufferedImage read(File input) | 读取本地磁盘图片文件 |
static BufferedImage read(InputStream input) | 读取本地磁盘图片文件 |
static boolean write(RenderedImage im,String formatName,File output) | 往磁盘中输入图片文件 |