Here you can find the source of getSizeRATIO(List
private static Size getSizeRATIO(List<Size> sizes, int w, int h)
//package com.java2s; import java.util.List; import android.hardware.Camera.Size; public class Main { private static Size getSizeRATIO(List<Size> sizes, int w, int h) { Size re = null;/*from w w w . j av a2s .c o m*/ double wantRatio = (double) w / (double) h; double minGap = wantRatio; for (Size size : sizes) { if (getRatioGap(size, wantRatio) < minGap) { minGap = getRatioGap(size, wantRatio); re = size; } } return re; } private static double getRatioGap(Size size, double wantRatio) { double sizeRatio = (double) size.height / (double) size.width; return Math.abs(sizeRatio - wantRatio); } }