Convert rectF To Rect - Android android.graphics

Android examples for android.graphics:RectF

Description

Convert rectF To Rect

Demo Code

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

public class Main {

  public static void rectFToRect(RectF rectF, Rect rect) {
    rect.left = Math.round(rectF.left);
    rect.top = Math.round(rectF.top);
    rect.right = Math.round(rectF.right);
    rect.bottom = Math.round(rectF.bottom);
  }//from w  w w . j  a v a 2 s  . c o m

  public static Rect rectFToRect(RectF rectF) {
    Rect rect = new Rect();
    rectFToRect(rectF, rect);
    return rect;
  }

}

Related Tutorials