Here you can find the source of getSizeLB(List
private static Size getSizeLB(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 getSizeLB(List<Size> sizes, int w, int h) { Size re = null;/*from w ww . j a va 2 s.c om*/ int wantSize = w * h; int minGap = wantSize; for (Size size : sizes) { if (getSizeGapValue(size, wantSize) > 0 && getSizeGapValue(size, wantSize) < minGap) { re = size; minGap = getSizeGap(size, wantSize); } } return re; } private static int getSizeGapValue(Size size, int wantSize) { return size.width * size.height - wantSize; } private static int getSizeGap(Size size, int wantSize) { return Math.abs(size.width * size.height - wantSize); } }