Example usage for android.graphics Bitmap getHeight

List of usage examples for android.graphics Bitmap getHeight

Introduction

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

Prototype

public final int getHeight() 

Source Link

Document

Returns the bitmap's height

Usage

From source file:Main.java

/**
 * Utility function to resize bitmap to a square
 * /*from w  ww  .j  av  a  2s  .  co m*/
 * @param bitmap the bitmap to crop
 * @return the cropped bitmap
 */
public static Bitmap cropBitMapToSquare(Bitmap bitmap) {
    int shortSideLen = Math.min(bitmap.getHeight(), bitmap.getWidth());
    return Bitmap.createBitmap(bitmap, 0, 0, shortSideLen, shortSideLen);
}

From source file:Main.java

public static String dump(Bitmap b) {
    return "bitmap " + b.getWidth() + " x " + b.getHeight();
}

From source file:Main.java

static public Bitmap scaleToFitHeight(Bitmap b, int height) {
    float factor = height / (float) b.getHeight();
    return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factor), height, false);
}

From source file:Main.java

public static Bitmap scaleToFitHeight(Bitmap b, int height) {
    float factor = height / (float) b.getHeight();
    return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factor), height, true);
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap source, float w, float h) {
    int height = source.getHeight();
    int width = source.getWidth();
    Matrix matrix = new Matrix();
    matrix.postScale(w / width, h / height);
    Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    return bitmap;
}

From source file:Main.java

public static int getBitmapByteCount(Bitmap bitmap) {
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:Main.java

private static boolean isEmptyBitmap(final Bitmap src) {
    return src == null || src.getWidth() == 0 || src.getHeight() == 0;
}

From source file:Main.java

public static byte[][] bitmap2grayByteArry(Bitmap bm) {
    byte[][] grayImage = new byte[bm.getHeight()][bm.getWidth()];
    for (int i = 0; i < bm.getWidth(); i++) {
        for (int j = 0; j < bm.getHeight(); j++) {
            if (bm.getPixel(i, j) == Color.WHITE) {
                grayImage[j][i] = 0;/*  w  ww. j  av a2s . c  om*/
            } else {
                grayImage[j][i] = 1;
            }
        }
    }
    return grayImage;
}

From source file:Main.java

public static Bitmap createTransparent(Bitmap bitmap) {
    return createTransparent(bitmap.getWidth(), bitmap.getHeight());
}

From source file:Main.java

public static Bitmap convertToAlphaMask(Bitmap b) {
    Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
    Canvas c = new Canvas(a);
    c.drawBitmap(b, 0.0f, 0.0f, null);/*from w  ww .  j  a  va2  s.  c  o  m*/
    return a;
}