get Bitmap Rect - Android Graphics

Android examples for Graphics:Bitmap Paint

Description

get Bitmap Rect

Demo Code


//package com.java2s;

import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;

public class Main {
    public static Rect getBitmapRect(PointF center, float radius) {
        RectF rectF = new RectF();
        rectF.set(center.x - radius, center.y - radius, center.x + radius,
                center.y + radius);/*from  w w w. ja v  a2s .c o m*/
        return rectF2Rect(rectF);
    }

    public static Rect rectF2Rect(RectF rectF) {
        Rect rect = new Rect();
        rect.set((int) rectF.left, (int) rectF.top, (int) rectF.right,
                (int) rectF.bottom);
        return rect;
    }
}

Related Tutorials