List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
public static double getPixel(int x, int y, Bitmap bitmap) { if (x < 0 || x >= bitmap.getWidth() || y < 0 || y >= bitmap.getHeight()) return 0; return bitmap.getPixel(x, y); }
From source file:Main.java
public static Bitmap setGrayscale(Bitmap source) { int width, height; height = source.getHeight(); width = source.getWidth();/*from w ww . j a v a2s. 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(source, 0, 0, paint); return bmpGrayScale; }
From source file:Main.java
public static Bitmap resizeBitmap(Bitmap bitmap, int maxSize) { int bigger = bitmap.getWidth() > bitmap.getHeight() ? bitmap.getWidth() : bitmap.getHeight(); if (bigger > maxSize) { float scale = bigger / maxSize; return scaleBitmap(bitmap, scale); } else {// w ww . ja v a 2 s . c om return bitmap; } }
From source file:Main.java
@Deprecated public static Bitmap setAlpha(Bitmap source, int number) { int[] argb = new int[source.getWidth() * source.getHeight()]; source.getPixels(argb, 0, source.getWidth(), 0, 0, source.getWidth(), source.getHeight()); number = number * 255 / 100;/*ww w . j a v a 2s .c o m*/ for (int i = 0; i < argb.length; i++) { argb[i] = (number << 24) | (argb[i] & 0x00FFFFFF); } return Bitmap.createBitmap(argb, source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); }
From source file:Main.java
public static Bitmap scaleBitmapWidth(Bitmap bitmap, int width) { float ratio = bitmap.getWidth() / bitmap.getHeight(); return scaleBitmap(bitmap, width, (width * bitmap.getHeight()) / bitmap.getWidth()); }
From source file:Main.java
public static Bitmap rotate(Bitmap bitmap, int degree) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(degree);//from ww w . ja v a 2 s . c o m return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
From source file:Main.java
public static Bitmap toOvalBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); Paint paint = new Paint(); paint.setAntiAlias(true);//from www. j a v a2 s . co m Rect rect = new Rect(0, 0, bitmap.getHeight(), bitmap.getHeight()); RectF rectF = new RectF(rect); canvas.drawOval(rectF, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rectF, paint); return output; }
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);/*from w w w . j a va 2 s .c o m*/ bitmap = Bitmap.createBitmap(bitmap, width / 2 - 10, height / 3 - 10, width / 2 + 10, height / 3 + 10, matrix, true); return bitmap; }
From source file:Main.java
private static Bitmap crop(Bitmap source) { int width = source.getWidth() - 2; int height = source.getHeight() - 2; if (width <= 0 || height <= 0) { return source; }// w w w. ja va 2 s . c om return Bitmap.createBitmap(source, 1, 1, width, height); }
From source file:Main.java
public static int getScreenPicHeight(int screenWidth, Bitmap bitmap) { int picWidth = bitmap.getWidth(); int picHeight = bitmap.getHeight(); int picScreenHeight; picScreenHeight = (screenWidth * picHeight) / picWidth; return picScreenHeight; }