欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

android中matrix的单位,Android中canvas和matrix之间的关系是什么?

发布时间:2025/3/20 Android 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android中matrix的单位,Android中canvas和matrix之间的关系是什么? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我读了这个画布概述:

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.drawBitmap(bitmap, matrix, paint);

换句话说,画布矩阵是否与位图矩阵不同?

我问这个,因为当我使用canvas.drawBitmap然后使用canvas.concat()然后绘制任何对象时,此对象在画布上进行相同的转换,所以我认为画布和位图具有相同的矩阵!

解决方法:

它们是不同的.当使用画布绘制提供矩阵的位图时,在内部,提供的矩阵连接到当前画布矩阵.

换句话说,调用canvas.drawBitmap(rectBitmap,matrix,paint);具有相同的效果:

canvas.save();

canvas.concat(matrix);

canvas.drawBitmap(rectBitmap, 0, 0, paint);

canvas.restore();

这解释了为什么你的对象正在进行相同的转换,因为你正在调用canvas.concat(matrix);然后绘制对象.

标签:android,bitmap,canvas,matrix,concat

来源: https://codeday.me/bug/20190609/1206444.html

总结

以上是生活随笔为你收集整理的android中matrix的单位,Android中canvas和matrix之间的关系是什么?的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。