Android_Canvas_Bitmap_关系
@作者 : 西野奈留
@博客: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-
更多相关文章
- android中的surface原理
- Android(安卓)平滑和立体翻页效果1
- Android触摸事件小小画板(7)
- Android简单画板的实现
- Android中常用的bitmap处理方法 (bitmap工具类)
- java me 与 android 缓冲绘图的一点点认识
- Android画图学习总结(二)——Bitmap
- Android实现简单画图画板
- [置顶] android 幻灯片效果之平移