List of usage examples for android.graphics Rect width
public final int width()
From source file:Main.java
public static boolean makesureSizeNotTooLarge(Rect paramRect) { return paramRect.width() * paramRect.height() * 2 <= 5242880; }
From source file:Main.java
public static float m2226a(Rect rect) { return ((float) rect.width()) / ((float) rect.height()); }
From source file:Main.java
public static float calculateAspectRatio(Rect paramRect) { return paramRect.width() / paramRect.height(); }
From source file:Main.java
public static int getSampleSizeOfNotTooLarge(Rect paramRect) { double d = paramRect.width() * paramRect.height() * 2.0D / 5242880.0D; if (d >= 1.0D) return (int) d; return 1;// ww w.j a va2 s . com }
From source file:Main.java
public static Bitmap resizeOuterFit(Bitmap src, Rect rect) { float aspectRatio = Math.max((float) rect.width() / src.getWidth(), (float) rect.height() / src.getHeight()); int newWidth = (int) (src.getWidth() * aspectRatio); int newHeight = (int) (src.getHeight() * aspectRatio); return Bitmap.createScaledBitmap(src, newWidth, newHeight, false); }
From source file:Main.java
public static Bitmap cutBitmap(Bitmap mBitmap, Rect r, Bitmap.Config config) { int width = r.width(); int height = r.height(); Bitmap croppedImage = Bitmap.createBitmap(width, height, config); Canvas cvs = new Canvas(croppedImage); Rect dr = new Rect(0, 0, width, height); cvs.drawBitmap(mBitmap, r, dr, null); return croppedImage; }
From source file:Main.java
public static Bitmap cropWithCanvas(Bitmap bitmap, Rect cropRect) { Rect destRect = new Rect(0, 0, cropRect.width(), cropRect.height()); Bitmap cropped = Bitmap.createBitmap(cropRect.width(), cropRect.height(), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(cropped); canvas.drawBitmap(bitmap, cropRect, destRect, null); return cropped; }
From source file:Main.java
/** * Calculates the aspect ratio given a rectangle. *///from ww w .j av a 2s. c o m public static float calculateAspectRatio(Rect rect) { return calculateAspectRatio(rect.width(), rect.height()); }
From source file:Main.java
public static Bitmap cropCenterInside(Bitmap src, Rect rect) { int width = Math.min(src.getWidth(), rect.width()); int height = Math.min(src.getHeight(), rect.height()); int[] rowData = new int[width]; int stride = src.getWidth(); int x = (src.getWidth() - width) / 2; int y = (src.getHeight() - height) / 2; Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); int delta = 0; while (delta < height) { src.getPixels(rowData, 0, stride, x, y + delta, width, 1); dest.setPixels(rowData, 0, stride, 0, delta, width, 1); delta++;//from ww w . j a v a2s. co m } return dest; }
From source file:Main.java
/** * Calculates the aspect ratio given a rectangle. *///from w ww .j a v a2s. c o m public static float calculateAspectRatio(Rect rect) { final float aspectRatio = (float) rect.width() / (float) rect.height(); return aspectRatio; }