android-Canvas

来源:互联网 发布:证件照拍照软件 编辑:程序博客网 时间:2024/05/02 01:23

The Canvas class holds the "draw" calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).

Canvas类控制着绘图。为了绘图,你需要是个基本的组成部分。

1. 一个Bitmap来控制每个像素点

2. 一个Canvas来控制绘图(绘制到bitmap)

3. 一个绘制的图形(直角,线,文本,bitmap)

4. 一个画笔(描绘要画的颜色和风格)


个人理解如下。

Bitmap 实际对应着的是实际设备的界面,是实际的像素点。

Canvas 对应着的是一个虚拟设备界面。

有4中的这只笔在2中这个画布上绘制3这样的图形,最后显示到1这个屏幕上。


 public void drawColor(int color)

Fill the entire canvas' bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode.

用指定的颜色填充整个canvas的bitmap。


 public void drawArc()

画弧线


public void drawARGB(int a, int r, int g, int b) 

用A透明度,RGB三原色填充canvas


public void drawBitmap()

画bitmap


public void drawCircle()

画圆


public void drawLine()

画线


 public void drawVertices()

Draw the array of vertices, interpreted as triangles (based on mode). 




0 0
原创粉丝点击