Android Canvas笔记

本文详细介绍了Canvas画图的基本功能,包括无限大的画布原理、画布平移概念及实现方式。同时,提供了画图后保存到本地文件的方法,并强调了Canvas中translate和rotate方法对坐标系的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Canvas画图相关
Canvas画图

•画布基本功能的一个大概讲解
http://www.jb51.net/article/38861.htm

Canvas画布我的理解是它本身是无限大的,但是代码获得的宽和高是与手机屏幕的分辨率有关系的。画布平移后依然可以作画。

•关于画布平移的解释
Translate - Basically do what it says. Just translate the canvas using x,y. If you want to draw two objects and the one is just translation of the other e.g x2 = x1 + 50 for each point . You don’t have to make all your calculations again for the second object but you can just translate the canvas and draw again the same object. I hope this example will help you

平移API的解释
•What does it mean to “preconcat” a matrix in Android?
When working with matrices, the word concatenation refers to multiplication.
Since matrix multiplication is not commutative, there is a separate word for backwards multiplication.
Pre-concatenating a to b means setting a = b × a. (As opposed to a = a × b, which will give a different matrix)

•如果画图后希望保存到本地文件参考
http://stackoverflow.com/questions/18676311/android-app-how-to-save-a-bitmap-drawing-on-canvas-as-image-check-code

Canvas中的translate方法会影响坐标系。
注意:Canvas中的rotate方法会连同坐标系一起旋转。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值