List of usage examples for android.graphics Matrix Matrix
public Matrix()
From source file:Main.java
public static Bitmap smallBitmap(Bitmap bitmap, float scale) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(scale, scale);//w w w . ja v a 2 s.co m Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); return newbmp; }
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap bmp, float rotation) { if (rotation == 0) { return bmp; }//from w w w . j a va 2 s . co m Matrix matrix = new Matrix(); matrix.postRotate(rotation); return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap scaleBitmapSoft(Bitmap temp, float scaleSize) { if (!canUse(temp)) { return null; }/* w ww .ja v a 2 s .co m*/ Matrix m = new Matrix(); m.postScale(scaleSize, scaleSize, 0, 0); return Bitmap.createBitmap(temp, 0, 0, temp.getWidth(), temp.getHeight(), m, true); }
From source file:Main.java
public static Bitmap rotateImageView(int angle, Bitmap bitmap) { if (bitmap == null) { return null; }//from w w w. ja v a2s .c o m Matrix matrix = new Matrix(); matrix.postRotate(angle); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return resizedBitmap; }
From source file:Main.java
public static Bitmap rotateFromDegree(Bitmap bitmap, int degree) { if (bitmap == null || degree == 0) return bitmap; Matrix matrix = new Matrix(); matrix.preRotate(degree);/*from w w w. j ava2s . c om*/ Bitmap mBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return mBitmap; }
From source file:Main.java
public static Bitmap resizeBitmap(Bitmap bitmap, float sx, float sy) { Bitmap newBitmap;//from ww w .j ava 2 s .co m Matrix matrix = new Matrix(); matrix.postScale(sx, sy); newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); return newBitmap; }
From source file:Main.java
public static Bitmap getTotateBitmap(Bitmap bitmap, int orientation) { Matrix matrix = new Matrix(); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: { matrix.setRotate(90);// w ww . j av a2 s. co m bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } break; case ExifInterface.ORIENTATION_ROTATE_180: { matrix.setRotate(180); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } break; case ExifInterface.ORIENTATION_ROTATE_270: { matrix.setRotate(270); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } break; default: break; } return bitmap; }
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap bmp, int degrees) { if (degrees != 0) { Matrix matrix = new Matrix(); matrix.postRotate(degrees % 360); return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); }/*from w w w .jav a 2s . co m*/ return bmp; }
From source file:Main.java
public static Bitmap zoom(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) w / width); float scaleHeight = ((float) h / height); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); }
From source file:Main.java
public static Bitmap decodeBitmap(Bitmap bitmap, int orientation) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(orientation);/*www . j a v a2 s . c o m*/ return Bitmap.createBitmap(bitmap, 0, 0, width, height, mtx, true); }