I am drawing a Bitmap over a Canvas and then doing some scaling on it, pretty simple, just using canvas.scale(int, int, pivot, pivot), and then, after the scaling is completed, I need to get the Bitmap's coordinates relative to the viewport. Is there any convenient way to do this without calculating by myself what the initial position is then where it went after the scale?
Actually, the Bitmap with the scaling can get bigger than the Canvas, so I need a开发者_JAVA技巧ctually the clip size of the view and the bitmap (the size of the area that is invisible and I suppose lower than x,y(0,0).
I am thinking this:
canvas.scale(scaleX, scaleY, pivotX, pivotY);
if (scaleX >= 1){
objectNewX = objectOldX + (objectOldX - pivotX)*(scaleX - 1);
}else{
objectNewX = objectOldX - (objectOldX - pivotX)*(1 - scaleX);
}
the same for Y and the other corner, this is off the top of my head, have not tried it...
精彩评论