List of usage examples for android.graphics Bitmap createBitmap
public static Bitmap createBitmap(@NonNull DisplayMetrics display, @NonNull @ColorInt int[] colors, int offset, int stride, int width, int height, @NonNull Config config)
From source file:Main.java
public static Bitmap getImageCrop(Bitmap bitmap) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); int wh = w > h ? h : w; int retX = w > h ? (w - h) / 2 : 0; int retY = w > h ? 0 : (h - w) / 2; return Bitmap.createBitmap(bitmap, retX, retY, wh, wh, null, false); }
From source file:Main.java
public static Bitmap zoom(Bitmap source, float width, float height) { Matrix matrix = new Matrix(); float scaleX = width / source.getWidth(); float scaleY = height / source.getHeight(); matrix.postScale(scaleX, scaleY);//from www .j a v a 2 s . co m Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); return bitmap; }
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);/*from ww w. ja v a2 s .c o m*/ Bitmap mScrewBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, true); return mScrewBitmap; }
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap bitmap, int rotate) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.postRotate(rotate);//from w ww. ja v a2 s . c o m return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false); }
From source file:Main.java
public static Bitmap rotate(Bitmap b, int degrees) { if (degrees != 0 && b != null) { Matrix m = new Matrix(); m.setRotate(degrees, (float) b.getWidth() / 2, (float) b.getHeight() / 2); try {/*from w w w. ja v a2 s . c om*/ Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), m, true); if (b != b2) { return b2; } else { return b; } } catch (OutOfMemoryError ex) { return b; } } return null; }
From source file:Main.java
public static Bitmap zoom(Bitmap source, float width, float height) { Matrix matrix = new Matrix(); float scaleW = width / source.getWidth(); float scaleH = height / source.getHeight(); matrix.postScale(scaleW, scaleH);/* www . j a v a2s .com*/ Bitmap bm = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); return bm; }
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap sourceBitmap, float angleInDegrees) { if (angleInDegrees == 0) return sourceBitmap; Matrix matrix = new Matrix(); matrix.postRotate(angleInDegrees);/* w ww . j a v a2 s . c o m*/ return Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, true); }
From source file:Main.java
private static Bitmap rotateBitmap(Bitmap bitmap, int rotate) { if (bitmap == null) { return null; }/* w w w . j ava 2 s . c o m*/ 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 zoomBitmap3(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float ratio = ((float) w / width); matrix.postScale(ratio, ratio);/*from www .j a v a 2 s.c om*/ Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return newbmp; }
From source file:Main.java
public static Bitmap zoomBMP(Bitmap bitmap, int height, int width) { int w = bitmap.getWidth(); int h = bitmap.getHeight() - 1; Matrix matrix = new Matrix(); float scaleHeight = ((float) height / h); matrix.postScale(scaleHeight, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); }