Example usage for android.graphics Bitmap getWidth

List of usage examples for android.graphics Bitmap getWidth

Introduction

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

Prototype

public final int getWidth() 

Source Link

Document

Returns the bitmap's width

Usage

From source file:Main.java

public static boolean isBitmapSquare(Bitmap bitmap) {
    return (bitmap.getWidth() == bitmap.getHeight());
}

From source file:Main.java

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

From source file:Main.java

private static Bitmap crop(Bitmap source) {
    int width = source.getWidth() - 2;
    int height = source.getHeight() - 2;
    if (width <= 0 || height <= 0) {
        return source;
    }// www  . j  a v  a 2 s. co m
    return Bitmap.createBitmap(source, 1, 1, width, height);
}

From source file:Main.java

public static int getScreenPicHeight(int screenWidth, Bitmap bitmap) {
    int picWidth = bitmap.getWidth();
    int picHeight = bitmap.getHeight();
    int picScreenHeight;
    picScreenHeight = (screenWidth * picHeight) / picWidth;
    return picScreenHeight;
}

From source file:Main.java

public static int getScreenPicHeight(int screenWidth, Bitmap bitmap) {
    int picWidth = bitmap.getWidth();
    int picHeight = bitmap.getHeight();
    int picScreenHeight = 0;
    picScreenHeight = (screenWidth * picHeight) / picWidth;
    return picScreenHeight;
}

From source file:Main.java

public static Bitmap getSquare(Bitmap bm) {
    int w = bm.getWidth();
    int h = bm.getHeight();
    int side = (w > h) ? h : w;
    return Bitmap.createBitmap(bm, 0, 0, side, side);
}

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 Bitmap getImageCrop(Bitmap bitmap) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    int wh = w > h ? h : w;

    int retX = w > h ? (w - h) / 2 : 0;
    int retY = w > h ? 0 : (h - w) / 2;

    return Bitmap.createBitmap(bitmap, retX, retY, wh, wh, null, false);
}

From source file:Main.java

private static Bitmap getBitmap(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.setScale(0.5f, 0.5f);//from w  ww.j a  v  a  2s .  c  o  m
    bitmap = Bitmap.createBitmap(bitmap, width / 2 - 10, height / 3 - 10, width / 2 + 10, height / 3 + 10,
            matrix, true);
    return bitmap;
}

From source file:Main.java

private static int calculateHeight(int width, Bitmap bitmap) {

    float bwinth = bitmap.getWidth();
    float bheight = bitmap.getHeight();

    float scale = bwinth / bheight;

    return (int) (width / scale);
}