List of usage examples for android.graphics Matrix Matrix
public Matrix()
From source file:Main.java
public static Bitmap rotate(@NonNull final Bitmap bitmap, final float angle) { final Matrix matrix = new Matrix(); matrix.postRotate(angle);//from w ww. j a v a 2 s .c o m return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap rotate(Bitmap bitmap, int degree) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(degree);/*from w w w. ja v a2s.com*/ return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
From source file:Main.java
public static Bitmap resize(Bitmap bmp, int width, int height) { float sx = (width * 1.0f) / bmp.getWidth(); float sy = (height * 1.0f) / bmp.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(sx, sy);/* w ww . ja v a2s . co m*/ return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap rotateBitmapDegree(Bitmap bm, int degree) { Bitmap returnBm;// ww w . j a va2 s . c om int w = bm.getWidth(); int h = bm.getHeight(); Matrix matrix = new Matrix(); matrix.postRotate(degree); returnBm = Bitmap.createBitmap(bm, 0, 0, w, h, matrix, true); if (bm != returnBm) { bm.recycle(); } return returnBm; }
From source file:Main.java
public static Bitmap getSkewBitmap(Bitmap mBitmap, float xRatio, float yRatio) { int width = mBitmap.getWidth(); int height = mBitmap.getHeight(); Matrix matrix = new Matrix(); matrix.postSkew(xRatio, yRatio);// w ww.j a v a 2s . c om Bitmap mScrewBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, true); return mScrewBitmap; }
From source file:Main.java
/** * TODO doc//from ww w . ja v a 2s. co m * * @param source * @return */ public static Bitmap flipVerticallyBitmap(Bitmap source) { Matrix m = new Matrix(); m.preScale(1, -1); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), m, false); }
From source file:Main.java
/** * TODO doc/*from ww w .java2 s .c o m*/ * * @param source * @return */ public static Bitmap flipHorizonallyBitmap(Bitmap source) { Matrix m = new Matrix(); m.setScale(-1, 1); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), m, false); }
From source file:Main.java
public static Bitmap createRotatedBitmap(Bitmap bm, float degree) { Bitmap bitmap = null;//from ww w. j a va2 s. c o m if (degree != 0) { Matrix matrix = new Matrix(); matrix.preRotate(degree); bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); } return bitmap; }
From source file:Main.java
private static Bitmap resizeBitmap(Bitmap bmp, float width, float height) { float xscale = width / bmp.getWidth(); float yscale = height / bmp.getHeight(); Matrix matrix = new Matrix(); // resize original image matrix.postScale(xscale, yscale);/*from ww w . j a v a2 s . com*/ Bitmap dstbmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); return dstbmp; }
From source file:Main.java
public final static Bitmap rotationBitmap(Bitmap srcBitmap, float degrees) { Bitmap result = null;/* w w w .j av a2 s . c o m*/ if (degrees != 0 && srcBitmap != null) { Matrix m = new Matrix(); m.setRotate(degrees, (float) srcBitmap.getWidth() / 2, (float) srcBitmap.getHeight() / 2); try { Bitmap b2 = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), m, true); if (srcBitmap != b2) { srcBitmap.recycle(); srcBitmap = b2; } result = b2; } catch (OutOfMemoryError ex) { ex.printStackTrace(); } } return result; }