Java-ImageObserver,BufferedImage,Graphics2D,Graphics

API:
ImageObserver : http://www.apihome.cn/api/java/ImageObserver.html
BufferedImage:http://www.apihome.cn/api/java/BufferedImage.html
Graphics2D:http://www.apihome.cn/api/java/Graphics2D.html
Graphics:http://www.apihome.cn/api/java/Graphics.html

ImageObserver是一个接口,ImageObserver就是Image的观察者,它时刻关注Image是否可用。
public abstract int getHeight(ImageObserver observer);

class MyPanel extends JPanel implements MouseListener, ImageObserver {

   BufferedImage bi;
   private static final long serialVersionUID = 1L;
   public MyPanel() {
       this.addMouseListener(this);
       bi = new BufferedImage(600, 400, 1);
   }
   public void paint(Graphics graphics) {
       super.paint(graphics);
       Graphics g2d = (Graphics2D) graphics;
       g2d.drawImage(bi, 100, 100, this);
   }

}

BufferedImage:
1. 在paint中new BufferedImage;
2. Graphics2D=bufferedimage.createGraphics();
3. Graphics2D.draw();
4. Graphics.drawImage().
public abstract void draw(Shape s)

使用当前 Graphics2D 上下文的设置勾画 Shape 的轮廓。应用的呈现属性包括 Clip、Transform、Paint、Composite 和 Stroke 属性。

Graphics2D,Graphics
Graphics2D提供对几何形状、坐标转换、颜色管理和文本布局更为复杂的控制;
Graphics 类是所有图形上下文的抽象基类,允许应用程序在组件(已经在各种设备上实现)以及闭屏图像上进行绘制
详细设计可以查阅:http://blog.csdn.net/cl18652469346/article/details/53117023

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值