I need to draw a bitmap inside of a specified rectangle. Why is it not drawn?
canvas.drawBitmap(MyBitmap, null, rectangle, null)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT
The original answer is incorrect.
You can use the sourceRect to specify a part of a Bitmap to draw.
It may be null, in which case the whole image will be used.
As per the fryer comment he was drawing beneath something, I’ll add a note on that.
drawBitmap(bitmap, srcRect, destRect, paint)does not handle Z
ordering (depth)and the order of calling draw on object matters.If you have 3 shapes to be drawn, square, triangle and circle. If you want the square to be on top then it must be drawn last.
You’re not specified any source, so its not drawn anything.
Example:
You have a Bitmap 100×100 pixels. You want to draw the whole Bitmap.
You want to draw only the left half of the bitmap.
You need to specify the source rect, the source rect can be a rectangle anywhere from 0,0 to the width,height of the bitmap.