Returns the shorter of the two bitmap dimensions to use for square-cropping. - Android Graphics

Android examples for Graphics:Bitmap Crop

Description

Returns the shorter of the two bitmap dimensions to use for square-cropping.

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    /**//from  w  w w  . j  a v  a2  s  . c o m
     * Returns the shorter of the two bitmap dimensions to use for square-cropping.
     * @param bitmap the bitmap to be cropped
     * @return the required dimension
     */
    public static int getCropDimensions(Bitmap bitmap) {
        if (bitmap.getWidth() >= bitmap.getHeight()) {
            return bitmap.getHeight();
        } else {
            return bitmap.getWidth();
        }
    }
}

Related Tutorials