List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
private static int calculateHeight(int width, Bitmap bitmap) { float bwinth = bitmap.getWidth(); float bheight = bitmap.getHeight(); float scale = bwinth / bheight; return (int) (width / scale); }
From source file:Main.java
public static double getDiv(Bitmap bitmap) { double width = bitmap.getWidth(); double height = bitmap.getHeight(); if (width != 0) { return height / width; }/*from www . j a va2 s . c o m*/ return 0; }
From source file:Main.java
public static Bitmap createBitmap(Bitmap bitmap, final String s) { bitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.parseColor(s)); return bitmap; }
From source file:Main.java
public static int getHeight(Bitmap btm, int newWidth) { float btmW = btm.getWidth(); float btmH = btm.getHeight(); // float scale=(btmW-newWidth)/btmW; // return (int)(btmH-btmH * scale); float scale = btmH / btmW; return (int) (newWidth * scale); }
From source file:Main.java
/** * Returns true if we should add padding to this icon. We use a heuristic that if the pixels in * all four corners of the icon are not transparent, we assume the icon is square and maximally * sized, i.e. in need of padding. Otherwise, no padding is added. *///from w w w . j a va2 s . c o m private static boolean shouldPadIcon(Bitmap icon) { int maxX = icon.getWidth() - 1; int maxY = icon.getHeight() - 1; if ((Color.alpha(icon.getPixel(0, 0)) != 0) && (Color.alpha(icon.getPixel(maxX, maxY)) != 0) && (Color.alpha(icon.getPixel(0, maxY)) != 0) && (Color.alpha(icon.getPixel(maxX, 0)) != 0)) { return true; } return false; }
From source file:Main.java
public static Bitmap cropSquareBitmap(Bitmap srcBmp) { Bitmap dstBmp;//from w w w. j a va2s . c om if (srcBmp.getWidth() >= srcBmp.getHeight()) { dstBmp = Bitmap.createBitmap(srcBmp, srcBmp.getWidth() / 2 - srcBmp.getHeight() / 2, 0, srcBmp.getHeight(), srcBmp.getHeight()); } else { dstBmp = Bitmap.createBitmap(srcBmp, 0, srcBmp.getHeight() / 2 - srcBmp.getWidth() / 2, srcBmp.getWidth(), srcBmp.getWidth()); } return dstBmp; }
From source file:Main.java
public static Bitmap getResizedBitmap(Bitmap bitmap, int i, int j) { int k = bitmap.getWidth(); int l = bitmap.getHeight(); float f = (float) i / (float) k; float f1 = (float) j / (float) l; Matrix matrix = new Matrix(); matrix.postScale(f, f1);//from w w w. ja va 2s .co m return Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, false); }
From source file:Main.java
public static Bitmap toGreyBitmap(Bitmap bitmap) { Bitmap grey = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(grey); Paint p = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0);//from w ww.ja va 2s . c om p.setColorFilter(new ColorMatrixColorFilter(cm)); c.drawBitmap(bitmap, 0, 0, p); return grey; }
From source file:Main.java
public static int getBitmapHeight(String path, String fileName) { Bitmap bitmap = BitmapFactory.decodeFile(path + fileName); return bitmap == null ? 0 : bitmap.getHeight(); }
From source file:Main.java
public static Bitmap addPadding(@NonNull Bitmap bmp) { int biggerParam = Math.max(bmp.getWidth(), bmp.getHeight()); Bitmap bitmap = Bitmap.createBitmap(biggerParam, biggerParam, bmp.getConfig()); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); int top = bmp.getHeight() > bmp.getWidth() ? 0 : (bmp.getWidth() - bmp.getHeight()) / 2; int left = bmp.getWidth() > bmp.getHeight() ? 0 : (bmp.getHeight() - bmp.getWidth()) / 2; canvas.drawBitmap(bmp, left, top, null); return bitmap; }