Example usage for android.graphics Rect Rect

List of usage examples for android.graphics Rect Rect

Introduction

In this page you can find the example usage for android.graphics Rect Rect.

Prototype

public Rect(int left, int top, int right, int bottom) 

Source Link

Document

Create a new rectangle with the specified coordinates.

Usage

From source file:Main.java

private static Rect getScreenRegion(int width, int height) {
    return new Rect(0, 0, width, height);
}

From source file:Main.java

public static Rect rect(final RectF rect) {
    return new Rect((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom);
}

From source file:Main.java

public static Rect buildRect(Bitmap bitmap, int left, int top) {
    return new Rect(left, top, left + bitmap.getWidth(), top + bitmap.getHeight());
}

From source file:Main.java

static public Rect getFrame(View v) {
    return new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
}

From source file:Main.java

static public Rect getPaddedFrame(View v) {
    return new Rect(v.getLeft() + v.getPaddingLeft(), v.getTop() + v.getPaddingTop(),
            v.getRight() - v.getPaddingRight(), v.getBottom() - v.getPaddingBottom());
}

From source file:Main.java

public static int drawIn(Canvas canvas, Bitmap bitmap, Rect display, int x) {
    if (bitmap != null) {
        Rect source = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        display = new Rect(display.left + x, display.top + x, display.right - x, display.bottom - x);
        canvas.drawBitmap(bitmap, source, display, null);
        return x + display.width();
    }/* w  w w  . j  a  va 2s .  co  m*/
    return 0;
}

From source file:Main.java

public static Rect adSizeForOrientation(int paramInt) {
    switch (paramInt) {
    }//from ww w. j  av a 2  s. c o m
    for (Rect localRect = new Rect(0, 0, 320, 50);; localRect = new Rect(0, 0, 480, 32)) {
        return localRect;
    }
}

From source file:Main.java

private static Rect getCollisionBounds(Rect rect1, Rect rect2) {
    int left = (int) Math.max(rect1.left, rect2.left);
    int top = (int) Math.max(rect1.top, rect2.top);
    int right = (int) Math.min(rect1.right, rect2.right);
    int bottom = (int) Math.min(rect1.bottom, rect2.bottom);
    return new Rect(left, top, right, bottom);
}

From source file:Main.java

public static Rect rect(final float left, final float top, final float right, final float bottom) {
    return new Rect((int) left, (int) top, (int) right, (int) bottom);
}

From source file:Main.java

public static Bitmap cutBitmap(Bitmap mBitmap, Rect r, Bitmap.Config config) {
    int width = r.width();
    int height = r.height();

    Bitmap croppedImage = Bitmap.createBitmap(width, height, config);

    Canvas cvs = new Canvas(croppedImage);
    Rect dr = new Rect(0, 0, width, height);
    cvs.drawBitmap(mBitmap, r, dr, null);
    return croppedImage;
}