List of usage examples for android.graphics Matrix Matrix
public Matrix()
From source file:Main.java
public static Bitmap getRotatedImg(String path) { int angle = getBitmapRotation(path); Matrix matrix = new Matrix(); matrix.postRotate(angle);/*from w w w .j a v a 2s . c o m*/ Bitmap bitmap = BitmapFactory.decodeFile(path); try { bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { Bitmap newbmp = null;/* ww w . ja v a 2s . c o 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); try { newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); } catch (Exception e) { newbmp = bitmap; } } return newbmp; }
From source file:Main.java
public static Bitmap resizeImage(Bitmap bitmap, int newWidth, int newHeight) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return resizedBitmap; }
From source file:Main.java
public static Bitmap getRotatedBitmap(byte[] bildDaten) { Bitmap result = BitmapFactory.decodeByteArray(bildDaten, 0, bildDaten.length); if (result.getWidth() > result.getHeight()) { Matrix m = new Matrix(); m.postRotate(90);// w ww .j ava 2 s.c om result = Bitmap.createBitmap(result, 0, 0, result.getWidth(), result.getHeight(), m, true); } return result; }
From source file:Main.java
public static Bitmap orientationBitMap(String filepath, Bitmap bit) { int orientation = getExifOrientation(filepath); if (orientation != 0) { Matrix matrix = new Matrix(); matrix.setRotate(orientation);/* w w w . j a v a2 s. c o m*/ return Bitmap.createBitmap(bit, 0, 0, bit.getWidth(), bit.getHeight(), matrix, true); } return bit; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Bitmap newbmp;/*from w w w . j a v a 2 s. co m*/ try { // if (h >= w) { // if (height <= h) { Matrix matrix = new Matrix(); float scaleHeight = ((float) height / h); matrix.postScale(scaleHeight, scaleHeight); newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); return newbmp; // } // } else { // if (width <= w) { // Matrix matrix = new Matrix(); // float scaleWidth = ((float) width / w); // matrix.postScale(scaleWidth, scaleWidth); // newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, // true); // return newbmp; // } // } } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Bitmap getRotatedBitmap(Bitmap imageBitmap, int screenRotation) { int rotationAdjustment = getRotationAdjustment(screenRotation); Matrix matrix = new Matrix(); matrix.postRotate(rotationAdjustment); return Bitmap.createBitmap(imageBitmap, 0, 0, imageBitmap.getWidth(), imageBitmap.getHeight(), matrix, true);/* w w w . ja va2 s .co m*/ }
From source file:Main.java
public static Bitmap rotateImage(Bitmap bitmap, float degrees) { Bitmap resultBitmap = bitmap;// www .jav a 2 s .c om try { Matrix matrix = new Matrix(); matrix.postRotate(degrees); // Rotate the bitmap resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } catch (Exception exception) { exception.printStackTrace(); } if (resultBitmap != bitmap) { bitmap.recycle(); } return resultBitmap; }
From source file:Main.java
public static Bitmap getResizedBitmap(Bitmap bm, float newWidth, float newHeight) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = newWidth / width; float scaleHeight = newHeight / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); }
From source file:Main.java
/** * Rotate the image.// w ww . j av a2s . c o 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); }