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

private static Bitmap rotate(Bitmap result, int rotation) {
    Matrix matrix = new Matrix();
    matrix.setRotate(rotation, (float) result.getWidth() / 2, (float) result.getHeight() / 2);

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

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int rotation) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotation);//from  w w  w  .  ja  v a 2 s.c om
    Bitmap rotatedbitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotatedbitmap;
}

From source file:Main.java

private static Bitmap rotateImage(Bitmap source, float angle) {

    Bitmap bitmap = null;/*from w w  w.j a  va  2s. co m*/
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    try {
        bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    } catch (OutOfMemoryError err) {
        err.printStackTrace();
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int degress, boolean needRecycle) {
    Matrix m = new Matrix();
    m.postRotate(degress);//from   w  w w  .j ava2s  .  c om
    Bitmap bm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
    if (needRecycle) {
        bitmap.recycle();
    }
    return bm;
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap src, float degree) {
    // create new matrix
    Matrix matrix = new Matrix();
    // setup rotation degree
    matrix.postRotate(degree);//from  w ww. jav  a  2  s.c  o m
    Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    return bmp;
}

From source file:Main.java

public static Bitmap rotateBmp(Bitmap bmp, int degree) {
    int w = bmp.getWidth();
    int h = bmp.getHeight();
    Matrix mtx = new Matrix();
    mtx.postRotate(degree);//from w w w. j  a v  a  2  s. co  m
    Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
    return rotatedBMP;
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap source, float angle) {
    Bitmap retVal;//  w w w . ja va2  s .c  o  m

    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    retVal = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);

    return retVal;
}

From source file:Main.java

public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);//w ww. j a  va2  s .  c  o m
    System.out.println("angle2=" + angle);
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    bitmap.recycle();
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap mirrorImage(@NonNull Bitmap resultBitmap) {
    Matrix matrix = new Matrix();
    matrix.preScale(-1.0f, 1.0f);//from   w w  w.  j  a va2  s.c om

    Bitmap returnBitmap = Bitmap.createBitmap(resultBitmap, 0, 0, resultBitmap.getWidth(),
            resultBitmap.getHeight(), matrix, false);

    resultBitmap.recycle();

    return returnBitmap;
}

From source file:Main.java

public static Bitmap scale(Bitmap org, float xRate, float yRate) {

    final int orgWidth = org.getWidth();
    final int orgHeight = org.getHeight();

    Matrix matrix = new Matrix();
    matrix.postScale(xRate, yRate);/* w  ww .j  av a 2 s .  co  m*/

    return Bitmap.createBitmap(org, 0, 0, orgWidth, orgHeight, matrix, true);
}