Android gets a Rect bitmap (left, top, right, bottom) on canvas

I draw a bitmap on top of the canvas and then do a little scaling on it, quite simply, just using canvas.scale (int, int, pivot, pivot), and then, after scaling is complete, I need to get the bitmap coordinates relative to the viewport. Is there any convenient way to do this without figuring out for myself what the initial position is, where did it go after the scale?

In fact, a scaled bitmap can increase more than Canvas, so I need the actual size of the clip for the presentation and bitmap (the size of the area that is invisible, and I assume lower than x, y (0, 0).

+4
source share
1 answer

I think so:

canvas.scale(scaleX, scaleY, pivotX, pivotY); if (scaleX >= 1){ objectNewX = objectOldX + (objectOldX - pivotX)*(scaleX - 1); }else{ objectNewX = objectOldX - (objectOldX - pivotX)*(1 - scaleX); } 

same for Y and another angle, this is from the top of the head, have not tried ...

+2
source

All Articles