List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
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
public static Bitmap roateImage(Bitmap mBitmap, float degree) { if (mBitmap.getWidth() > mBitmap.getHeight()) { Matrix matrix = new Matrix(); matrix.postRotate(degree);//from ww w.j a v a 2 s. c o m mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true); } return mBitmap; }
From source file:Main.java
public static Bitmap toRoundCorner(Bitmap bitmap) { int height = bitmap.getHeight(); int width = bitmap.getHeight(); Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, width, height); paint.setAntiAlias(true);/*from w w w. ja v a2s . c o m*/ canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.TRANSPARENT); canvas.drawCircle(width / 2, height / 2, width / 2, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }
From source file:Main.java
public static Bitmap toRoundCorner(Bitmap bitmap) { int height = bitmap.getHeight(); int width = bitmap.getHeight(); Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, width, height); paint.setAntiAlias(true);// www . j av a 2s. c om canvas.drawARGB(0, 0, 0, 0); //paint.setColor(0xff424242); paint.setColor(Color.TRANSPARENT); canvas.drawCircle(width / 2, height / 2, width / 2, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }
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 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
static public Bitmap strechToFill(Bitmap b, int width, int height) { float factorH = height / (float) b.getHeight(); float factorW = width / (float) b.getWidth(); return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorW), (int) (b.getHeight() * factorH), true); }
From source file:Main.java
public static void openLrucache() { lruCache = new LruCache<String, Bitmap>((int) Runtime.getRuntime().maxMemory() / 8) { @Override/*w w w .j av a 2 s . com*/ protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); } }; }
From source file:Main.java
public static Bitmap getSquare(Bitmap bm) { int w = bm.getWidth(); int h = bm.getHeight(); int side = (w > h) ? h : w; return Bitmap.createBitmap(bm, 0, 0, side, side); }
From source file:Main.java
static public Bitmap strechToFill(Bitmap b, int width, int height) { float factorH = height / (float) b.getHeight(); float factorW = width / (float) b.getWidth(); return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorW), (int) (b.getHeight() * factorH), false); }