0

Is the Android documentation for canvas.drawBitmap wrong? It says:

public void drawBitmap (Bitmap bitmap, float left, float top, Paint paint)

Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.

Well, x and y don’t seem to be floats, they’re ints; is that correct? Say I want to overlay the bitmap (which is the size of the available screen, and is bound to a canvas of the same) over the whole available screen. It seems sensible I would: canvas.drawBitmap(myBitmap, 0, 0, mPaint); doesn’t it? But that doesn’t work. What does seem to work is: canvas.drawBitmap(myBitmap, 2000000, 1000000, mPaint). Now that statement seems to me to tell the bitmap that it should draw itself a huge distance Outside the screen! What am I missing here?

4

1 回答 1

1

在这种方法中x,andy是浮点数,而不是整数。但就像文档中提到的那样,位图的xy坐标将受到当前在Canvas. 例如,在aScrollView的情况下,矩阵很可能包含非常大的平移。

这意味着坐标0, 0将在当前原点绘制位图Canvas。该原点由您可以使用查询的矩阵定义getMatrix()

于 2013-02-08T01:14:37.360 回答