0

I am having trouble with drawing a bitmap to a surfaceview with the canvas.drawBitmap(Bitmap, Rect, Rect, Paint) method.

When i put somethign like this:

canvas.drawBitmap(square, new Rect(0, 0, 100, 100), new Rect(180, 130, 100, 100), mpaint);

it renders something like this:

http://s21.postimg.org/69jlkn71j/image.png

and if i put something like this:

canvas.drawBitmap(square, new Rect(0, 0, 100, 100), new Rect(50, 90, 100, 100), mpaint);

the screen looks like this:

http://s9.postimg.org/qvp9635vj/image.png

it really wear, i've tried all ways, but it doesn't work. Do yo have any idea of whats happening? has it something to do with the lockcanvas() and unlockcanvasandpost() process?

i would really aprecciate your help, i've been here for hours.

oh, i forgot to mention that when i put the square in full screen:

canvas.drawBitmap(square, new Rect(0, 0, 100, 100), new Rect(0, 0, this.getWidth(), this.getHeight()), mpaint);

it draws it just as it should be....

Andre Silva
  • 4,782
  • 9
  • 52
  • 65
Yamil Essus
  • 108
  • 9
  • what do you want to do? man you can say what you want in 1 or 2 lines. – Alex Mar 23 '13 at 21:51
  • I didn't understand what your problem actually is, but maybe you are not using correctly second and third argument when calling canvas.drawBitmap(). take a look at the [reference](http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.RectF,%20android.graphics.Paint%29) it could be useful – lelloman Mar 23 '13 at 22:21

0 Answers0