List of usage examples for android.graphics Matrix postRotate
public boolean postRotate(float degrees)
From source file:Main.java
/** * Rotate the image./*from w w w.java 2 s . co m*/ * * @param drawable */ public static BitmapDrawable rotateImage(BitmapDrawable drawable, int degree) { Bitmap bitmap = drawable.getBitmap(); Matrix matrix = new Matrix(); matrix.postRotate(degree); Bitmap rotatedBMP = Bitmap.createBitmap(drawable.getBitmap(), 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return new BitmapDrawable(rotatedBMP); }
From source file:Main.java
public static Bitmap rotateImage(@NonNull Bitmap in, int angle) { Matrix mat = new Matrix(); mat.postRotate(angle); return Bitmap.createBitmap(in, 0, 0, in.getWidth(), in.getHeight(), mat, true); }
From source file:Main.java
public static Bitmap rotateImageView(int angle, Bitmap bitmap) { if (bitmap == null) return null; Matrix matrix = new Matrix(); matrix.postRotate(angle); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);/*from w w w .j a v a 2 s . c o m*/ if (bitmap != null && !bitmap.isRecycled()) { bitmap = null; } // bitmap.recycle(); return resizedBitmap; }
From source file:Main.java
public static Bitmap yuv2bitmap(byte[] data, int width, int height) { ByteArrayOutputStream out = new ByteArrayOutputStream(); YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, null); yuvImage.compressToJpeg(new android.graphics.Rect(0, 0, width, height), 100, out); byte[] imageBytes = out.toByteArray(); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); // rotate//from w ww . jav a 2 s. com Matrix matrix = new Matrix(); matrix.postRotate(90); Bitmap dst = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return dst; }
From source file:Main.java
public static Bitmap rotaingImageView(int paramInt, Bitmap paramBitmap) { Matrix localMatrix = new Matrix(); localMatrix.postRotate(paramInt); return Bitmap.createBitmap(paramBitmap, 0, 0, paramBitmap.getWidth(), paramBitmap.getHeight(), localMatrix, true);//from w ww . j av a 2 s . c o m }
From source file:Main.java
public static Bitmap rotateBitmapDegree(Bitmap bm, int degree) { Bitmap returnBm;/* w ww . ja va 2 s . co m*/ 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 correctOrientation(Bitmap bitmap, int orientation) { Matrix matrix = new Matrix(); matrix.postRotate(orientation); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap createBitmapFromByteArray(byte[] data, Size previewSize) { YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, previewSize.width, previewSize.height, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); yuvimage.compressToJpeg(new Rect(0, 0, previewSize.width, previewSize.height), 80, baos); byte[] jdata = baos.toByteArray(); BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inMutable = true;//from ww w. j a v a2s . c om Bitmap bitmap = BitmapFactory.decodeByteArray(jdata, 0, jdata.length, opt); Matrix matrix = new Matrix(); matrix.postRotate(-90); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap rotateImage(Bitmap src, float degree) { // create new matrix Matrix matrix = new Matrix(); // setup rotation degree matrix.postRotate(degree); Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); return bmp;/* w ww. jav a 2s. c o m*/ }