normalize Rect from Bitmap - Android Graphics

Android examples for Graphics:Bitmap Paint

Description

normalize Rect from Bitmap

Demo Code


//package com.java2s;
import android.graphics.Bitmap;

import android.graphics.Rect;

public class Main {
    public static void normalizeRect(Rect rect, Bitmap normal) {
        rect.left = Math.max(rect.left, 0);
        rect.top = Math.max(rect.top, 0);
        rect.right = Math.min(rect.right, normal.getWidth());
        rect.bottom = Math.min(rect.bottom, normal.getHeight());
    }/*  www  .jav  a2s.  c  om*/
}

Related Tutorials