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 rotate(int rotateDegree, Bitmap originalBitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotateDegree);/*from   www .j  av  a  2s .  c  om*/
    Bitmap rotateBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(),
            originalBitmap.getHeight(), matrix, true);
    return rotateBitmap;
}

From source file:Main.java

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

From source file:Main.java

private static Bitmap rotaingImageView(Bitmap bitmap, int angle) {
    Matrix matrix = new Matrix();
    ;//w  w  w  . j  a v  a  2s  .c  o m
    matrix.postRotate(angle);
    Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotateBitmap;
}

From source file:Main.java

public static Bitmap getRotateBitmap(Bitmap b, float rotateDegree) {
    Matrix matrix = new Matrix();
    matrix.postRotate((float) rotateDegree);
    Bitmap rotaBitmap = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, false);
    return rotaBitmap;
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap src, float scaleX, float scaleY) {
    Matrix matrix = new Matrix();
    matrix.setScale(scaleX, scaleY);//from w  ww .jav a 2 s.  c  o  m
    Bitmap t_bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    return t_bitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int degrees) {
    if (degrees == 0) {
        return bitmap;
    }//from ww w.j  a  v  a2 s .  c  o m

    Matrix matrix = new Matrix();
    matrix.postRotate(degrees);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap scaleBitmap(Bitmap bitmap, float widthRatio, float heightRatio) {
    Matrix matrix = new Matrix();
    matrix.postScale(widthRatio, heightRatio);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);//from   ww  w . j  a v  a 2 s  .  c  o  m
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap bmp, int degrees) {
    if (degrees != 0) {
        Matrix matrix = new Matrix();
        matrix.postRotate(degrees);/*from  w ww . jav a 2 s.c o m*/
        return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
    }
    return bmp;
}

From source file:Main.java

public static Bitmap rotateOrientation(Bitmap bmp, int rotation) {
    try {//  w w w.j a  va 2  s.c  om
        Matrix matrix = new Matrix();
        matrix.postRotate(rotation);
        return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}