List of usage examples for android.graphics Bitmap getWidth
public final int getWidth()
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(); matrix.postScale((float) width / w, (float) height / h); return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { 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); 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 w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = (float) w / (float) width; float scaleHeight = (float) h / (float) height; matrix.postScale(scaleWidth, scaleHeight); 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); }
From source file:Main.java
public static Bitmap toCircleBitmap(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); int r = width < height ? width : height; Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(buffer); Paint paint = new Paint(); paint.setAntiAlias(true);//from w w w . ja va 2 s . c o m RectF rect = new RectF(0, 0, r, r); canvas.drawCircle(r / 2, r / 2, r / 2, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, null, rect, paint); bitmap.recycle(); return buffer; }
From source file:Main.java
public static Bitmap postRotateBitamp(Bitmap bmp, float degree) { int bmpWidth = bmp.getWidth(); int bmpHeight = bmp.getHeight(); Matrix matrix = new Matrix(); matrix.postRotate(degree);/*from w ww . j a va2 s. co m*/ Bitmap resizeBmp = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true); return resizeBmp; }
From source file:Main.java
public static Bitmap getRoundBitmap(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap out = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(out); Paint paint = new Paint(); paint.setColor(Color.WHITE);// ww w . ja v a 2 s. co m paint.setAntiAlias(true); canvas.drawCircle(width / 2, height / 2, width / 2, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); Rect rect = new Rect(0, 0, width, height); canvas.drawBitmap(bitmap, rect, rect, paint); return out; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = (float) w / (float) width; float scaleHeight = (float) h / (float) height; matrix.postScale(scaleWidth, scaleHeight); Bitmap newBmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return newBmp; }
From source file:Main.java
public static Bitmap getCanvasBitmap(Bitmap bm, int width, int height) { int w = bm.getWidth(); int h = bm.getHeight(); if (w < width || h < height) { Log.e("bitmaputils", "bitmap target size is not "); return bm; }//from w w w . j av a 2 s. c om Bitmap bitmap = Bitmap.createBitmap(bm, (w - width) / 2, (h - height) / 2, width, height); return bitmap; }
From source file:Main.java
public static Bitmap compressAccordingToWidth(Bitmap bitmap, int width) { if (width == bitmap.getWidth()) { return bitmap; }/*from w w w. ja v a 2 s .c o m*/ float scale = (float) width / (float) bitmap.getWidth(); int height = (int) (bitmap.getHeight() * scale); return ThumbnailUtils.extractThumbnail(bitmap, width, height, 0); }