Rect,Path,Text...android绘制常用对象解析

要自己绘制一些东西,你需要4样基本的组件:
1,Bitmap对象存放像素点
2,Canvas对象用于调用具体的绘制(写入bitmap)
3,绘制的基本元素(如Rect,Path,text,Bitmap等)
4,Paint对象描述颜色和样式
下面将一一介绍
<strong>Bitmap</strong>
Bitmap是Android系统中的图像处理的最重要类之一。用它可以获取图像文件信息,进行图像剪切、旋转、缩放等操作,并可以指定格式保存图像文件。
bitmap便是位图的概念,可以由ALPHA_8, RGB_565, ARGB_4444(已废弃), ARGB_8888表示颜色信息


<strong>Rect:</strong>
看它名字便知它代表一个矩形,那它是怎么描述这个矩形的呢?下面是他构造函数。
[code lang="java"]/**
     * Create a new rectangle with the specified coordinates. Note: no range
     * checking is performed, so the caller must ensure that left <= right and
     * top <= bottom.
     *
     * @param left   The X coordinate of the left side of the rectangle
     * @param top    The Y coordinate of the top of the rectangle
     * @param right  The X coordinate of the right side of the rectangle
     * @param bottom The Y coordinate of the bottom of the rectangle
     */
    public Rect(int left, int top, int right, int bottom) {
        this.left = left;
        this.top = top;
        this.right = right;
        this.bottom = bottom;
    }[/code]
它有4个int成员,分别代表左上右下,你可以理解为两个点,前两个int组成矩形的左上角xy坐标,后两个int组成右下角xy坐标。
rect
android 的SDK绘制图形以屏幕的左上角为坐标原点,真应该从ios那个偷来的概念


Rect常用于绘制。如canvas.drawRect(new Rect(15, 15, 140, 70), mPaint); 


更多内容:http://www.flakor.cn/2014-04-24-326.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值