1

I used this function in my Android program:

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

However, I want to draw my bitmap not in the position 0 x 0, but in the position 10 x 10 (in PIXELS). The drawBitmap function, however, only accepts float numbers...

How can I achieve this??

Thank you in advance!

mskfisher
  • 3,291
  • 4
  • 35
  • 48
  • Have you tried `drawBitmap(bitmap, 10.f, 10.f, ... )`... Considering the transformation matrix of the canvas is set to the identity matrix, that is – K-ballo May 07 '12 at 02:06
  • Oh, god. I can`t believe I haven`t tried that... It worked! Thanks K-ballo! Just one more question. Why is it that those parameters use float then? I just didn`t get it. – Bitcoin Cash - ADA enthusiast May 07 '12 at 03:44
  • The documentation is just so poor in my opinion... It just says that the parameters are float number, but it doesn`t give one single example or explains what those float numbers really are. – Bitcoin Cash - ADA enthusiast May 07 '12 at 06:49

1 Answers1

0

Have you tried drawBitmap(bitmap, 10.f, 10.f, ... )? Considering the transformation matrix of the canvas is set to the identity matrix, that is.

The reason those parameters are float is probably that the Canvas does not operate in an integer space (pixels), but in a user specified space defined by a transformation matrix. If you where to set a custom transformation matrix to scale by 2 then using 0.5, 0.5 would end up mapping to pixel 1, 1. This means you could also set a custom transformation to translate by 10, 10 and then just simply draw the bitmap without specifying a destination.

K-ballo
  • 80,396
  • 20
  • 159
  • 169