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 overlayToDownRightCorner(Bitmap bmp1, Bitmap bmp2) {
    Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
    Canvas canvas = new Canvas(bmOverlay);
    canvas.drawBitmap(bmp1, new Matrix(), null);
    Matrix matrix = new Matrix();
    matrix.setTranslate(bmp1.getWidth() - bmp2.getWidth(), bmp1.getHeight() - bmp2.getHeight());
    canvas.drawBitmap(bmp2, matrix, null);
    return bmOverlay;
}

From source file:Main.java

public static Bitmap zoomBitmap3(Bitmap bitmap, int w, int h) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    float ratio = ((float) w / width);

    matrix.postScale(ratio, ratio);//from w w  w.ja v  a  2  s  . c o m
    Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return newbmp;
}

From source file:Main.java

public static Bitmap toCircleBitmap(Bitmap bitmap) {

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int r = width < height ? width : height;

    Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(buffer);
    Paint paint = new Paint();
    paint.setAntiAlias(true);//from  w ww .j  a  v  a 2  s.  c  om
    RectF rect = new RectF(0, 0, r, r);

    canvas.drawCircle(r / 2, r / 2, r / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, null, rect, paint);
    bitmap.recycle();
    return buffer;
}

From source file:Main.java

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

From source file:Main.java

public static Bitmap circleCrop(Bitmap bitmap) {
    int size = Math.min(bitmap.getWidth(), bitmap.getHeight());

    Bitmap output = Bitmap.createBitmap(size, size, Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, size, size);

    paint.setAntiAlias(true);//from   w ww  .ja v a  2 s.  c o m
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    // canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    canvas.drawCircle(size / 2, size / 2, size / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    // Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
    // return _bmp;
    return output;
}

From source file:Main.java

public static Bitmap postRotateBitamp(Bitmap bmp, float degree) {

    int bmpWidth = bmp.getWidth();
    int bmpHeight = bmp.getHeight();

    Matrix matrix = new Matrix();
    matrix.postRotate(degree);/*w  w  w. j  a v  a2 s.c  o  m*/
    Bitmap resizeBmp = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
    return resizeBmp;
}

From source file:Main.java

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

From source file:Main.java

public static int getProportionFullWidthHeight(int screenWidth, Bitmap bitmap, Context context) {
    double width = bitmap.getWidth();
    double height = bitmap.getHeight();
    double proportion = screenWidth / width;
    double proportionHeight = height * proportion;
    return (int) proportionHeight;
}

From source file:Main.java

public static Bitmap getRoundBitmap(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Bitmap out = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(out);
    Paint paint = new Paint();
    paint.setColor(Color.WHITE);/*from   w  w w.  j  a v  a 2s .c o m*/
    paint.setAntiAlias(true);
    canvas.drawCircle(width / 2, height / 2, width / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    Rect rect = new Rect(0, 0, width, height);
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return out;
}

From source file:Main.java

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