Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw Image on right bottom corner of the canvas?

In My application i want to set the image on the canvas at the right bottom corner. So How i have to set that image in canvas ?

like image 338
Shreyash Mahajan Avatar asked Nov 14 '11 09:11

Shreyash Mahajan


2 Answers

canvas.drawBitmap(bitmap , canvas.getWidth()-bitmap.getWidth() , canvas.getHeight()-bitmap.getHeight() , paint);

like image 130
Shailendra Singh Rajawat Avatar answered Oct 18 '22 19:10

Shailendra Singh Rajawat


Get the x and y coordinates by some simple calculation

Pseudo Code

x = canvas.width - image.width - padding
y = canvas.height - image.height - padding
canvas.drawBitmap(x,y,....)

EDIT: x = Math.max(0,x); and y = Math.max(0,y); incase the image is bigger than the canvas.

like image 23
st0le Avatar answered Oct 18 '22 19:10

st0le