List of usage examples for android.graphics Matrix setScale
public void setScale(float sx, float sy)
From source file:Main.java
/** * Method to flip horizontally a Bitmap. * * @param source The original Bitmap.//from ww w .ja v a 2 s .c o m * @return The flipped Bitmap. */ public static Bitmap flipHorizonally(Bitmap source) { Matrix m = new Matrix(); m.setScale(-1, 1); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), m, false); }
From source file:Main.java
/** * TODO doc/*from www .j a v a 2 s . c om*/ * * @param source * @return */ public static Bitmap flipHorizonallyBitmap(Bitmap source) { Matrix m = new Matrix(); m.setScale(-1, 1); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), m, false); }
From source file:Main.java
public static Bitmap scale(Bitmap src, float scale) { if (src == null) { return null; }/*from w w w. j a v a2 s . c o m*/ Matrix m = new Matrix(); m.setScale(scale, scale); return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, true); }
From source file:Main.java
public static Bitmap getSolideSizeBitmap(Bitmap bm, int width, int height) { float widthScale = (width * 1f) / (bm.getWidth() * 1f); float heightScale = (height * 1f) / (bm.getHeight() * 1f); Matrix matrix = new Matrix(); matrix.setScale(widthScale, heightScale); return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, false); }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap src, float scaleX, float scaleY) { Matrix matrix = new Matrix(); matrix.setScale(scaleX, scaleY); Bitmap t_bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); return t_bitmap; }
From source file:Main.java
private static Bitmap getBitmap(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.setScale(0.5f, 0.5f); bitmap = Bitmap.createBitmap(bitmap, width / 2 - 10, height / 3 - 10, width / 2 + 10, height / 3 + 10, matrix, true);/*from ww w . j ava2 s . c om*/ return bitmap; }
From source file:Main.java
public static Bitmap scaleBitmap(Bitmap bitmap, int reW, int reH) { if (bitmap == null) { return null; }/*from w ww . j a va2 s. c o m*/ int bmpW = bitmap.getWidth(); int bmpH = bitmap.getHeight(); float wScale = reW * 1.0f / bmpW; float hScale = reH * 1.0f / bmpH; float scale = Math.max(wScale, hScale); Matrix matrix = new Matrix(); matrix.setScale(scale, scale); return Bitmap.createBitmap(bitmap, 0, 0, bmpW, bmpH, matrix, true); }
From source file:Main.java
public static void drawBitmapCenter(Canvas canvas, float f, float f1, float f2, boolean flag, boolean flag1, Bitmap bitmap, Paint paint) { if (flag) {/* w w w. j a va 2 s . c om*/ f -= (f2 * (float) bitmap.getWidth()) / 2.0F; } if (flag1) { f1 -= (f2 * (float) bitmap.getHeight()) / 2.0F; } Matrix matrix = new Matrix(); matrix.setScale(f2, f2); matrix.postTranslate(f, f1); canvas.drawBitmap(bitmap, matrix, paint); }
From source file:Main.java
public static Bitmap getBitmap(Bitmap background, Bitmap contour, float alpha) { Paint paint = new Paint(); paint.setAntiAlias(true);// w ww .ja v a 2s . c o m paint.setColor(Color.WHITE); paint.setDither(false); Bitmap bitmap = Bitmap.createBitmap(contour.getWidth(), contour.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Matrix m = new Matrix(); m.setScale(contour.getWidth() * 1.0f / background.getWidth(), contour.getHeight() * 1.0f / background.getHeight()); paint.setAlpha((int) (alpha * 0xff)); canvas.drawBitmap(background, m, paint); paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); paint.setAlpha(0xff); canvas.drawBitmap(contour, 0, 0, paint); return bitmap; }
From source file:Main.java
public static Bitmap getFlippedBitmap(Resources res, int resId) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true;//from w w w . j av a2 s . c o m //Below line is necessary to fill in opt.outWidth, opt.outHeight Bitmap b = BitmapFactory.decodeResource(res, resId, opt); b = Bitmap.createBitmap(opt.outWidth, opt.outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); Matrix flipHorizontalMatrix = new Matrix(); flipHorizontalMatrix.setScale(-1, 1); flipHorizontalMatrix.postTranslate(b.getWidth(), 0); Bitmap bb = BitmapFactory.decodeResource(res, resId); canvas.drawBitmap(bb, flipHorizontalMatrix, null); return b; }