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 rotateImage(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);/* ww  w .  j  a  v  a2  s.  com*/
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap resizeBitmap(Bitmap bm, float scale) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);/*from  www . ja va 2s.  c o m*/
    return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap zoomBitmap(float scale, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);/* ww w. j  a  va  2  s. co  m*/
    Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    return newBitmap;
}

From source file:Main.java

public static Bitmap flipBitmap(Bitmap src) {
    Matrix m = new Matrix();
    m.preScale(-1, 1);//from  ww  w .jav a 2s .c o  m
    Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
    dst.setDensity(DisplayMetrics.DENSITY_DEFAULT);
    return dst;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap source, int degree) {
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);//w ww.j a va 2  s . c  o  m
    Bitmap temp = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    if (null != source && !source.isRecycled()) {
        source.recycle();
        source = null;
    }
    return temp;
}

From source file:Main.java

public static Bitmap create180RotatedBitmap(Bitmap srcbmp, Bitmap.Config config) {
    Matrix m = new Matrix();
    m.postRotate(180.0F);/*w  w w.  ja  va 2 s .  c o m*/
    Bitmap newBmp = Bitmap.createBitmap(srcbmp, 0, 0, srcbmp.getWidth(), srcbmp.getHeight(), m, true);
    return newBmp;
}

From source file:Main.java

public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);/*from w w w.  j av a2  s .  c om*/
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int rotation) {
    Matrix matrix = new Matrix();
    matrix.preRotate(rotation);/*w w w .j  a  v a2 s.  co  m*/
    Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotatedBitmap;
}

From source file:Main.java

private static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);/*from  w  w w.j  a va 2 s. c  om*/
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap scaleWithXY(Bitmap src, float scaleX, float scaleY) {
    Matrix matrix = new Matrix();
    matrix.postScale(scaleX, scaleY);//from w w w. j  a v  a  2 s.  com
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}