Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Canvas;
import android.graphics.Color;

import android.graphics.Paint;
import android.graphics.Paint.Style;

import android.graphics.Rect;

public class Main {
    /**
     * Draw the face rect in the Image
     * @param canvas
     * @param face
     * @param width
     * @param height
     * @param frontCamera
     */
    static public void drawFaceRect(Canvas canvas, Rect rect, int width, int height, boolean frontCamera) {

        if (canvas == null)
            return;

        Paint paint = new Paint();
        paint.setColor(Color.rgb(57, 138, 243));
        int len = (rect.bottom - rect.top) / 8;
        if (len / 8 >= 2)
            paint.setStrokeWidth(len / 8);
        else
            paint.setStrokeWidth(2);

        if (frontCamera) {
            int left = rect.left;
            rect.left = width - rect.right;
            rect.right = width - left;
        }

        paint.setStyle(Style.STROKE);
        canvas.drawRect(rect, paint);
    }
}