List of usage examples for android.graphics Bitmap getWidth
public final int getWidth()
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 int[] getPixels(Bitmap bit) { int w = bit.getWidth(), h = bit.getHeight(); int pixels[] = new int[w * h]; bit.getPixels(pixels, 0, w, 0, 0, w, h); return pixels; }
From source file:Main.java
private static Bitmap getSquareBitmap(Bitmap srcBitmap) { int size = Math.min(srcBitmap.getWidth(), srcBitmap.getHeight()); int paddingX = (srcBitmap.getWidth() - size) / 2; int paddingY = (srcBitmap.getHeight() - size) / 2; return Bitmap.createBitmap(srcBitmap, paddingX, paddingY, size, size); }
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);/* ww w . ja v a 2 s . com*/ Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); return newbmp; }
From source file:Main.java
private static boolean isEmptyBitmap(Bitmap src) { return src == null || src.getWidth() == 0 || src.getHeight() == 0; }
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); }
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
public static final Bitmap scaleToHeight(Bitmap bitmap, int height) { int width = height * bitmap.getWidth() / bitmap.getHeight(); return Bitmap.createScaledBitmap(bitmap, width, height, true); }
From source file:Main.java
public static Bitmap convertToAlphaMask(Bitmap b) { Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8); Canvas c = new Canvas(a); c.drawBitmap(b, 0.0f, 0.0f, null);// w ww .jav a 2s . c o m return a; }
From source file:Main.java
public static int[] bitmapToIntArray(Bitmap bitmap) { final int bitmapWidth = bitmap.getWidth(); final int bitmapHeight = bitmap.getHeight(); int[] colors = new int[bitmapWidth * bitmapHeight]; bitmap.getPixels(colors, 0, bitmapWidth, 0, 0, bitmapWidth, bitmapHeight); return colors; }