Android examples for Graphics:Rectangle
scale Rectangle
import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.RectF; import android.view.View; public class Main{ public static Rect scale(RectF src, RectF parent, Scale scaleFactor) { return scale(src, scaleFactor.scaleX, scaleFactor.scaleY, parent); }// w ww . ja v a2 s. c o m public static Rect scale(RectF src, float scaleX, float scaleY, RectF parent) { int parentX = 0; int parentY = 0; if (parent != null) { parentX = (int) parent.left; parentY = (int) parent.top; } int newX = (int) ((src.left - parentX) * scaleX) + parentX; int newY = (int) ((src.top - parentY) * scaleY) + parentY; int newWidth = (int) (src.width() * scaleX); int newHeight = (int) (src.height() * scaleY); return new Rect(newX, newY, newX + newWidth, newY + newHeight); } }