且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是Canvas和位图之间的关系?

更新时间:2022-06-24 14:52:00

基本上,画布位图支持,当您用帆布画什么的话,在画布将绘制成位图它与创建。所以,当你使用画布绘制这两个位图,它要复合的位图一起,结果将存储在 drawingBitmap ,因为它支持画布。

Basically, the Canvas is backed by a Bitmap, so when you draw anything using the canvas, the canvas will draw into the Bitmap it was created with. So, when you draw those two bitmaps using the canvas, it's going to composite the bitmaps together and the result will be stored in drawingBitmap, as it's backing the canvas.

映的比喻是正确的十岁上下,虽然可能混淆(和过度简化,这我也做以上) - 正如我在评论中提到,你能想到的画布$的C $ C>为笔,在油漆作为笔(如更换墨盒或东西 - 任何你可以放入一个可配置的笔的想法)的配置,和位图为你画到纸上。如果你过于注重单词的接受的意思的比喻变得扑朔迷离。

Anh's analogy is correct-ish, though probably confusing (and over-simplifying, which I'm also doing above) – as I mentioned in a comment, you can think of the Canvas as the pen, the Paint as a configuration of that pen (e.g., replaceable ink or something - whatever you can fit into the idea of a configurable pen), and the Bitmap as the paper you draw onto. The analogy becomes confusing if you focus too much on the accepted meaning of the words.