List of usage examples for java.lang Math min
@HotSpotIntrinsicCandidate public static double min(double a, double b)
From source file:Main.java
public static int findBestSampleSize(int actualWidth, int actualHeight, int desiredWidth, int desiredHeight) { double wr = (double) actualWidth / desiredWidth; double hr = (double) actualHeight / desiredHeight; double ratio = Math.min(wr, hr); float n = 1.0f; while ((n * 2) <= ratio) { n *= 2;//w w w .j av a 2 s. co m } return (int) n; }
From source file:Main.java
public static int getVideoHeight(Activity activity) { return Math.min(getScreenWidth(activity) * VIDEO_HEIGHT_RATIOS / VIDEO_WIDTH_RATIOS, getScreenHeight(activity));/*from w w w . j a v a 2 s. c o m*/ }
From source file:Main.java
private static int findBestSampleSize(int actualWidth, int actualHeight, int desiredWidth, int desiredHeight) { double wr = (double) actualWidth / desiredWidth; double hr = (double) actualHeight / desiredHeight; double ratio = Math.min(wr, hr); float n = 1.0f; while ((n * 2) <= ratio) { n *= 2;/*ww w .j ava 2 s . c o m*/ } return (int) n; }
From source file:Main.java
/** * Utility function to resize bitmap to a square * /*from ww w . j a va 2 s. c o m*/ * @param bitmap the bitmap to crop * @return the cropped bitmap */ public static Bitmap cropBitMapToSquare(Bitmap bitmap) { int shortSideLen = Math.min(bitmap.getHeight(), bitmap.getWidth()); return Bitmap.createBitmap(bitmap, 0, 0, shortSideLen, shortSideLen); }
From source file:Main.java
public static int getMiniSize(String imagePath) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;//from w w w . ja v a 2s . c o m BitmapFactory.decodeFile(imagePath, options); return Math.min(options.outHeight, options.outWidth); }
From source file:Main.java
public static <O> List<List<O>> split(List<O> l, int targetSize) { List<List<O>> groups = new ArrayList<List<O>>(); for (int i = 0; i < l.size(); i += targetSize) { groups.add(l.subList(i, Math.min(i + targetSize, l.size()))); }//w w w .j av a 2 s. c om return groups; }
From source file:Main.java
/** * * @param activity/* w w w . jav a 2s. c om*/ * @return */ public static int getDisplaySmallerSideSize(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); return Math.min(display.getHeight(), display.getWidth()); }
From source file:Main.java
public static byte[] copyOfRange(byte[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(""); byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy;/*from w ww. j a v a 2s. c o m*/ }
From source file:Main.java
public static <V> List<V> subList(List<V> list, int startIndex, int count) { if (null == list || startIndex >= list.size() || count <= 0) { return Collections.emptyList(); }/* w ww . java 2 s . c o m*/ int endIndex = Math.min(startIndex + count, list.size()); return list.subList(startIndex, endIndex); }
From source file:Main.java
public static float adjust(final float value, final float min, final float max) { return Math.min(Math.max(min, value), max); }