List of usage examples for android.graphics Bitmap getWidth
public final int getWidth()
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 .jav a 2 s . co m return 0; }
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); }//from ww w . ja v a2 s .com Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, width, height, false); return scaledBitmap; }
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); }/*from ww w.j a va 2 s . co m*/ } return rgbArray; }
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 rotateBmp(Bitmap bmp, int degree) { int w = bmp.getWidth(); int h = bmp.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(degree);/*from ww w.ja va 2 s . c om*/ Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true); return rotatedBMP; }
From source file:Main.java
public static Bitmap createTransparent(Bitmap bitmap) { return createTransparent(bitmap.getWidth(), bitmap.getHeight()); }
From source file:Main.java
public static int getPixelsCount(Bitmap bitmap) { int hlen = bitmap.getWidth(), vlen = bitmap.getHeight(); int toReturn = 0; for (int i = 0; i < vlen; i++) { for (int j = 0; j < hlen; j++) { if ((bitmap.getPixel(j, i) & 0xff) > 0) { toReturn++;//from w w w .java 2s . c om } } } return toReturn; }
From source file:Main.java
public static Bitmap roateImage(Bitmap mBitmap, float degree) { if (mBitmap.getWidth() > mBitmap.getHeight()) { Matrix matrix = new Matrix(); matrix.postRotate(degree);/*from w w w . j a v a 2 s . c om*/ mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true); } return mBitmap; }
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);//w ww . j a va 2 s. co m return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
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. *//*w w w. j a v a 2s. 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; }