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

public static Bitmap getCircularBitmapImage(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());
    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;
    Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
    if (squaredBitmap != source) {
        source.recycle();//from   w  ww. jav  a2s . co m
    }
    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP,
            BitmapShader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setAntiAlias(true);
    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);
    squaredBitmap.recycle();
    return bitmap;
}

From source file:Main.java

public static Bitmap getCanvasBitmap(Bitmap bm, int width, int height) {
    int w = bm.getWidth();
    int h = bm.getHeight();
    if (w < width || h < height) {
        Log.e("bitmaputils", "bitmap target size is not ");
        return bm;
    }/*from ww w. j a  v a 2 s .  com*/
    Bitmap bitmap = Bitmap.createBitmap(bm, (w - width) / 2, (h - height) / 2, width, height);
    return bitmap;
}

From source file:Main.java

public static boolean isEmpty(Bitmap image) {
    return image == null || image == EMPTY_BITMAP || (image.getWidth() == 1 && image.getHeight() == 1);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap bitmap, float scale) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);//from w  w  w . j a  v  a 2s  . c  o m
    Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return newbmp;
}

From source file:Main.java

public static boolean checkBitmap(Bitmap bitmap) {
    if (null == bitmap || bitmap.isRecycled() || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
        return false;
    }//from  www  .  j  ava2  s  .c o m
    return true;
}

From source file:Main.java

public static Bitmap revertImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { -1, 0, 0, 1, 1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);/*  w w w  .j a  v  a  2 s .  c o m*/
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int rotate) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    Matrix matrix = new Matrix();
    matrix.postRotate(rotate);/*from w w  w.j  a  v a  2  s .  c  om*/

    return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
}

From source file:Main.java

public static Bitmap decodeBitmap(Bitmap bitmap, int orientation) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix mtx = new Matrix();
    mtx.postRotate(orientation);//from   ww  w. j  a  v a 2  s  . c o m
    return Bitmap.createBitmap(bitmap, 0, 0, width, height, mtx, true);
}