List of usage examples for android.graphics Matrix Matrix
public Matrix()
From source file:Main.java
private static Bitmap rotateBitmap(Bitmap bitmap, int rotate) { if (bitmap == null) { return null; }/*from ww w. jav a 2s .c om*/ int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(rotate); return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float x = (float) w / width; float y = (float) h / height; matrix.postScale(x, y);//from www . ja v a2 s.c om Bitmap zoomBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return zoomBitmap; }
From source file:Main.java
public static WeakReference<Bitmap> rotateBitmap(WeakReference<Bitmap> bitmap, int degress) { if (bitmap == null || bitmap.get() == null) return null; Matrix m = new Matrix(); m.postRotate(degress);/*from w w w.java2s .co m*/ return new WeakReference<Bitmap>(Bitmap.createBitmap(bitmap.get(), 0, 0, bitmap.get().getWidth(), bitmap.get().getHeight(), m, true)); }
From source file:Main.java
/** * @return matrix with correct configuration for the front camera. * Function to set correct height orientation and rotation for saving the image * in sd card.//from w ww .j a v a 2s . c om */ public static Matrix setOrientationForFrontCamera() { Matrix matrix = new Matrix(); matrix.postRotate(-90); //for mirror images float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1 }; Matrix matrixMirrorY = new Matrix(); matrixMirrorY.setValues(mirrorY); matrix.postConcat(matrixMirrorY); return matrix; }
From source file:Main.java
/** * Method using rotate photo.//w w w . ja va 2 s.co m * * @param bitmap Value bitmap current. * @param angle Value angle. * @return Bitmap. */ private static Bitmap rotateImage(Bitmap bitmap, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { Bitmap newbmp = null;//from w w w . ja va 2s .co m if (bitmap != null) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidht = ((float) w / width); float scaleHeight = ((float) h / height); matrix.postScale(scaleWidht, scaleHeight); newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); } return newbmp; }
From source file:Main.java
public static Bitmap adjustPhotoRotation(Bitmap bm, final int orientationDegree) { Matrix m = new Matrix(); m.setRotate(orientationDegree, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2); float targetX, targetY; if (orientationDegree == 90) { targetX = bm.getHeight();/*w ww .j av a2s . c om*/ targetY = 0; } else { targetX = bm.getHeight(); targetY = bm.getWidth(); } final float[] values = new float[9]; m.getValues(values); float x1 = values[Matrix.MTRANS_X]; float y1 = values[Matrix.MTRANS_Y]; m.postTranslate(targetX - x1, targetY - y1); Bitmap bm1 = Bitmap.createBitmap(bm.getHeight(), bm.getWidth(), Bitmap.Config.ARGB_8888); Paint paint = new Paint(); Canvas canvas = new Canvas(bm1); canvas.drawBitmap(bm, m, paint); return bm1; }
From source file:Main.java
/** * Method to flip vertically a Bitmap./*from w ww .j a v a2s.co m*/ * * @param source The original Bitmap. * @return The flipped Bitmap. */ public static Bitmap flipVertically(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
public static Bitmap rotateBitmap(Bitmap bitmap, int rotate) { if (bitmap == null) return null; int w = bitmap.getWidth(); int h = bitmap.getHeight(); // Setting post rotate to 90 Matrix mtx = new Matrix(); mtx.postRotate(rotate);/*from w ww .ja va 2s. c o m*/ return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
From source file:Main.java
private static Bitmap rotateBitmap(Bitmap bitmap, int rotate) { if (bitmap == null) return null; int w = bitmap.getWidth(); int h = bitmap.getHeight(); // Setting post rotate to 90 Matrix mtx = new Matrix(); mtx.postRotate(rotate);/* w w w . ja va 2 s . c o m*/ return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }