Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 *  COPYRIGHT NOTICE  
 *  Copyright (C) 2015, Jhuster <lujun.hust@gmail.com>
 *  https://github.com/Jhuster/Android
 *   
 *  @license under the Apache License, Version 2.0 
 *
 *  @file    BitmapHelper.java
 *  @brief   Bitmap processor, include load,save,rotate,crop etc.
 *  
 *  @version 1.0     
 *  @author  Jhuster
 *  @date    2015/11/20    
 */

import android.graphics.Bitmap;

import android.graphics.Canvas;

import android.graphics.Rect;

public class Main {
    public static Bitmap cropWithCanvas(Bitmap bitmap, Rect cropRect) {
        Rect destRect = new Rect(0, 0, cropRect.width(), cropRect.height());
        Bitmap cropped = Bitmap.createBitmap(cropRect.width(), cropRect.height(), Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(cropped);
        canvas.drawBitmap(bitmap, cropRect, destRect, null);
        return cropped;
    }
}