0
votes

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?

1
Android documentation is correct, (0,0) is the top left corner of the screen. Can you edit your question with your codes.NaviRamyle
"transformed by the current matrix.", have you check to make sure do not have some translations in your canvas matrix?iagreen

1 Answers

1
votes

In this method x and y are floats, not ints. But like mentioned in the documentation, the x and y coordinates of the bitmaps will be affected by the matrix currently set on the Canvas. In the case of a ScrollView for instance, the matrix could very well contain a very large translation.

What this means is that the coordinates 0, 0 will draw the bitmap at the current origin of the Canvas. That origin is defined by the matrix you can query with getMatrix().