@作者 : 西野奈留
@博客:http://blog.csdn.net/narunishino
-2016/4/09-

Canvas:(中文翻译)n.帆布,vt.用帆布覆盖。

primitive:(中文翻译)n.原始事物。

http://developer.android.com/reference/android/graphics/Canvas.html

android.graphics.Canvas

Class Overview //文档中的解释。
The Canvas class holds the “draw” calls. To draw something, you need 4 basic components:
1. A Bitmap to hold the pixels,
2. a Canvas to host the draw calls (writing into the bitmap),
3. a drawing primitive (e.g. Rect, Path, text, Bitmap),
4. a paint (to describe the colors and styles for the drawing).

平时看到的资料都把Canvas比喻成画布。

今天深入的去了解了一下,似乎不是画布哦,应该比喻成 画板 更加贴切。

而bitmap是画板(Canvas)上的那张白纸。

Canvas的2个构造方法:

1.public Canvas ()

Construct an empty raster canvas. Use setBitmap() to specify a bitmap to draw into. The initial target density is DENSITY_NONE; this will typically be replaced when a target bitmap is set for the canvas.

2.public Canvas (Bitmap bitmap)

Construct a canvas with the specified bitmap to draw into. The bitmap must be mutable.

从第一个构造方法的解释中可以看到,如果不给Canvas指定bitmap的话,系统会自动给Canvas一个bitmap1。

这时候如果你指定一个bitmap2给Canvas的话,你指定的这个bitmap2就会把原来系统默认的bitmap1给替换掉。

也就是说,你把画板(Canvas)中的原来就有的白纸(bitmap1)换成了你自己的白纸(bitmap2)(如果你之前在上面(bitmap2)画过东西的话就不是白纸了,反正就是换成你自己的纸)。

从源码的角度来解释的话,请看这里http://lwn.me/2014/04/13/canvas/

-End-

更多相关文章

  1. android中的surface原理
  2. Android(安卓)平滑和立体翻页效果1
  3. Android触摸事件小小画板(7)
  4. Android简单画板的实现
  5. Android中常用的bitmap处理方法 (bitmap工具类)
  6. java me 与 android 缓冲绘图的一点点认识
  7. Android画图学习总结(二)——Bitmap
  8. Android实现简单画图画板
  9. [置顶] android 幻灯片效果之平移

随机推荐

  1. 最近在翻译国外一本新书 The Android Dev
  2. Android事务 IMMEDIATE与EXCLUSIVE模式
  3. Android消息提示框和对话框
  4. android 在google商店里搜索不到的问题
  5. Android GirdView
  6. Android 4编程入门经典
  7. [Android实例] 【Kris专题】android 换
  8. Android中常用的Intent启动服务
  9. Android layout xml总结(1)
  10. Android(安卓)滚动事件 OnScrollListener