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 getSaturationBitmap(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Bitmap faceIconGreyBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(faceIconGreyBitmap);
    Paint paint = new Paint();
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0);// www.  j  ava 2  s. co m
    ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix);
    paint.setColorFilter(colorMatrixFilter);
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return faceIconGreyBitmap;
}

From source file:Main.java

public static Bitmap scaleByHeight(Bitmap bitmap, int newHeight) {
    return scale(bitmap, (float) newHeight / bitmap.getHeight());
}

From source file:Main.java

public static Bitmap overlay(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);
    canvas.drawBitmap(bmp2, 0, 0, null);
    return bmOverlay;
}

From source file:Main.java

public static Bitmap doInvert(Bitmap src) {
    Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
    int A, R, G, B;
    int pixelColor;
    int w = src.getWidth();
    int h = src.getHeight();
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            pixelColor = src.getPixel(x, y);
            A = Color.alpha(pixelColor);
            R = 255 - Color.red(pixelColor);
            G = 255 - Color.green(pixelColor);
            B = 255 - Color.blue(pixelColor);
            bmOut.setPixel(x, y, Color.argb(A, R, G, B));
        }//from   w  w w. j  av  a2  s . co m
    }
    return bmOut;
}

From source file:Main.java

public static final Bitmap grey(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Bitmap greyBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(greyBitmap);
    Paint paint = new Paint();
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0);//from   w  w  w  . j av  a 2s.co m
    ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix);
    paint.setColorFilter(colorMatrixFilter);
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return greyBitmap;
}

From source file:Main.java

public static Bitmap desaturateImage(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.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1,
            0, 0, 0, 1, 0 };//from w  w  w .j  a  v a 2 s.com

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

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

    return bitmap;
}

From source file:Main.java

public static Bitmap memoriesImage(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[] { 0.393f, 0.769f, 0.189f, 0, 0, 0.349f, 0.686f, 0.168f, 0, 0, 0.272f, 0.534f,
            0.134f, 0, 0, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);/*from  w  ww. j a  v  a2  s. com*/
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

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

    return bitmap;
}

From source file:Main.java

public static Rect buildRect(Bitmap bitmap, int left, int top) {
    return new Rect(left, top, left + bitmap.getWidth(), top + bitmap.getHeight());
}

From source file:Main.java

public static Bitmap resizeBitmapToFitWidth(Bitmap bm, int width) {
    int oriWidth = bm.getWidth();
    int oriHeight = bm.getHeight();
    if (oriWidth < width) {
        return bm;
    } else {//from ww w  .j  av a2s  . c om
        int height = (int) ((float) width / oriWidth * oriHeight);
        Bitmap tmp = Bitmap.createScaledBitmap(bm, width, height, false);
        bm.recycle();
        return tmp;
    }
}

From source file:Main.java

public static Bitmap generateGrayImage(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[] { 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f,
            0, 0, 0, 0, 0, 1, 0 };//from  ww  w.ja va 2 s  .  c  o m

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

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

    return bitmap;
}