List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
public static Bitmap CompressBitmap(Bitmap image) { int width = image.getWidth(); int height = image.getHeight(); float scale = 500.0f / height; if (width > 500 || height > 500) { width = Math.round(width * scale); height = Math.round(height * scale); }/*w w w . ja v a 2 s . co m*/ Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, width, height, false); return scaledBitmap; }
From source file:Main.java
public static int getScreenPicHeight(int screenWidth, Bitmap bitmap) { int picWidth = bitmap.getWidth(); int picHeight = bitmap.getHeight(); int picScreenHeight = 0; picScreenHeight = (screenWidth * picHeight) / picWidth; return picScreenHeight; }
From source file:Main.java
public static Bitmap scaleBitmapHeight(Bitmap bitmap, int height) { float ratio = bitmap.getWidth() / bitmap.getHeight(); return scaleBitmap(bitmap, height, (height * bitmap.getWidth()) / bitmap.getHeight()); }
From source file:Main.java
public static Bitmap createScaledToCenterInsideBitmap(Bitmap bitmap, int reqWidth, int reqHeight) { final int height = bitmap.getHeight(); final int width = bitmap.getWidth(); float widthScaleF = (float) width / (float) reqWidth; float heightScaleF = (float) height / (float) reqHeight; if (widthScaleF > heightScaleF) { return Bitmap.createScaledBitmap(bitmap, reqWidth, (int) (height / widthScaleF), true); } else {/*from ww w . ja v a 2s .co m*/ return Bitmap.createScaledBitmap(bitmap, (int) (width / heightScaleF), reqHeight, true); } }
From source file:Main.java
public static Bitmap smallBitmap(Bitmap bitmap, float scale) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(scale, scale);/* w w w. j a va 2s .c o m*/ Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); return newbmp; }
From source file:Main.java
public static int[][] getImageARGB(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); final int[][] rgbArray = new int[width][height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { rgbArray[i][j] = bitmap.getPixel(i, j); }/* w ww . j a v a 2s. c o m*/ } return rgbArray; }
From source file:Main.java
public static Bitmap autoResizeByWidth(Bitmap bitmap, int width) { float w = bitmap.getWidth(); float h = bitmap.getHeight(); int height = (int) (h / w * width); return resize(bitmap, width, height); }
From source file:Main.java
public static Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth();/*w w w .j a v a 2s . co m*/ Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:Main.java
public static Bitmap changeBitmapColor(Bitmap bmp, int color) { Bitmap b = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig()); Canvas canvas = new Canvas(b); Paint paint = new Paint(); paint.setColor(color);//from w ww . ja va 2s . com paint.setAntiAlias(true); canvas.drawBitmap(bmp, bmp.getWidth(), bmp.getHeight(), paint); return b; }
From source file:Main.java
public static Bitmap autoResizeByHeight(Bitmap bitmap, int height) { float w = bitmap.getWidth(); float h = bitmap.getHeight(); int width = (int) (w / h * height); return resize(bitmap, width, height); }