List of usage examples for android.graphics Matrix Matrix
public Matrix()
From source file:Main.java
/** * Calculates the transformation matrix according to M(transformation) * M(source) = M(target). * * @param source source matrix/*from www. j a v a 2 s . c o m*/ * @param target target matrix * @return delta matrix */ public static Matrix getTransformationMatrix(Matrix source, Matrix target) { Matrix delta = new Matrix(); source.invert(delta); delta.postConcat(target); return delta; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) width / w); float scaleHeight = ((float) height / h); matrix.postScale(scaleWidth, scaleHeight); Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); return newbmp; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, float sx, float sy) { Matrix matrix = new Matrix(); matrix.postScale(sx, sy);//from w w w.ja v a2s . c o m return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) { int i = bitmap.getWidth(); int j = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.preScale(1.0F, -1F);/*ww w . ja v a 2s . c o m*/ Bitmap bitmap1 = Bitmap.createBitmap(bitmap, 0, j / 2, i, j / 2, matrix, false); Bitmap bitmap2 = Bitmap.createBitmap(i, j + j / 2, android.graphics.Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap2); canvas.drawBitmap(bitmap, 0.0F, 0.0F, null); Paint paint = new Paint(); canvas.drawRect(0.0F, j, i, j + 4, paint); canvas.drawBitmap(bitmap1, 0.0F, j + 4, null); Paint paint1 = new Paint(); paint1.setShader(new LinearGradient(0.0F, bitmap.getHeight(), 0.0F, 4 + bitmap2.getHeight(), 0x70ffffff, 0xffffff, android.graphics.Shader.TileMode.CLAMP)); paint1.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN)); canvas.drawRect(0.0F, j, i, 4 + bitmap2.getHeight(), paint1); return bitmap2; }
From source file:Main.java
/** * Method to rotate a Bitmap specifying the angle. * * @param source The original Bitmap.// ww w.j av a2 s . co m * @param angle float that represents the rotation angle. * @return The rotated Bitmap. */ public static Bitmap rotate(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 zoomBitmap(Bitmap bitmap, float w, float h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleW = ((float) w / width); float scaleH = ((float) h / height); matrix.postScale(scaleW, scaleH);/*from w w w . j a v a2 s.c om*/ Bitmap newBmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return newBmp; }
From source file:Main.java
/** * reversal bitmap at left-right/*from www.ja v a2 s . c o m*/ * * @param originalImage * @return the bitmap after reversal */ public static Bitmap createReversal(Bitmap originalImage) { int width = originalImage.getWidth(); int height = originalImage.getHeight(); Matrix matrix = new Matrix(); matrix.preScale(-1.0f, 1.0f); return Bitmap.createBitmap(originalImage, 0, 0, width, height, matrix, false); }
From source file:Main.java
public static Bitmap scaleImage(Bitmap bitmap, int destW, int destH) { if (bitmap == null) { return null; }/*from w w w. java 2 s . com*/ int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = ((float) destW) / width; float scaleHeight = ((float) destH) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return scaledBitmap; }
From source file:Main.java
/** * scale image/*from www . j a v a 2 s.c o m*/ * * @param org * @param scaleWidth sacle of width * @param scaleHeight scale of height * @return */ public static Bitmap scaleImage(Bitmap org, float scaleWidth, float scaleHeight) { if (org == null) { return null; } Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(org, 0, 0, org.getWidth(), org.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap scaleImg(Bitmap bm, int newWidth, int newHeight) { int width = bm.getWidth(); int height = bm.getHeight(); int newWidth1 = newWidth; int newHeight1 = newHeight; float scaleWidth = ((float) newWidth1) / width; float scaleHeight = ((float) newHeight1) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); return newbm; }