Example usage for android.graphics Bitmap createBitmap

List of usage examples for android.graphics Bitmap createBitmap

Introduction

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

Prototype

public static Bitmap createBitmap(@NonNull DisplayMetrics display, @NonNull @ColorInt int[] colors, int offset,
        int stride, int width, int height, @NonNull Config config) 

Source Link

Document

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

Usage

From source file:Main.java

public static Bitmap cropBitmap(Bitmap source, int x, int y, int width, int height) {
    Bitmap bmp = Bitmap.createBitmap(source, x, y, width, height, null, false);
    if (source != null && bmp != source) {
        source.recycle();/*from   www .ja v  a 2  s  .c o m*/
    }
    return bmp;
}

From source file:Main.java

public static Bitmap flip(Bitmap src) {
    Matrix m = new Matrix();
    m.preScale(-1, 1);/*from   w  ww  .  j  a  va  2  s  . c  o  m*/
    Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
    return dst;
}

From source file:Main.java

private static Bitmap rotateBitmap(Bitmap bmp, int degrees) {
    Matrix matrix = new Matrix();
    matrix.postRotate(degrees);/*from   w  w  w . j  a v a 2s  .com*/

    Bitmap newBmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
    bmp.recycle();

    return newBmp;
}

From source file:Main.java

public static Bitmap LoadFliped(Bitmap src) {
    Matrix matrix = new Matrix();
    matrix.preScale(-1.0f, 1.0f);//from  www  . j a v  a2 s  . c  o  m

    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap doRotate(Bitmap b, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);//ww w  .ja  v a  2s .  c om
    b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);
    return b;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap) {

    Matrix matrix = new Matrix();
    matrix.postRotate(90f);/* ww  w .  j a va2 s.  c o m*/

    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap LoadFlipedVertical(Bitmap src) {
    Matrix matrix = new Matrix();
    matrix.preScale(1.0f, -1.0f);//from  w ww.  j  a  v  a2  s.  co  m
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap doScale(Bitmap b, float scale) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);//w w  w .  j  av a  2 s .c  o  m
    b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);
    return b;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap origin, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);/*ww w .ja  v  a2 s. c o  m*/
    return Bitmap.createBitmap(origin, 0, 0, origin.getWidth(), origin.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap zoom(Bitmap bitmap, float zf) {
    Matrix matrix = new Matrix();
    matrix.postScale(zf, zf);//from   w  w  w.j a v a  2s  .  c  om
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}