crop Bitmap - Android Graphics

Android examples for Graphics:Bitmap Crop

Description

crop Bitmap

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    static public Bitmap cropBitmap(Bitmap src, int x, int y, int width,
            int height, boolean isRecycle) {
        if (x == 0 && y == 0 && width == src.getWidth()
                && height == src.getHeight()) {
            return src;
        }//  w w w .j a va 2  s.co m
        Bitmap dst = Bitmap.createBitmap(src, x, y, width, height);
        if (isRecycle && dst != src) {
            src.recycle();
        }
        return dst;
    }
}

Related Tutorials