Here you can find the source of getSizeWIDTH(List
private static Size getSizeWIDTH(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 getSizeWIDTH(List<Size> sizes, int w, int h) { int wantWidth = w; Size re = null;/*from w w w. j a v a 2 s.co m*/ int minGap = w; for (Size size : sizes) { if (getWidthGap(size, wantWidth) < minGap) { minGap = getWidthGap(size, wantWidth); re = size; } } return re; } private static int getWidthGap(Size size, int wantWidth) { return Math.abs(size.height - wantWidth); } }