Java tutorial
//package com.java2s; import android.hardware.Camera; import android.hardware.Camera.Size; import java.util.List; public class Main { public static Size determineTargetPictureSize(Camera.Parameters params, int desiredResolution) { List<Size> sizes = params.getSupportedPictureSizes(); Size targetSize = sizes.get(0); int delta = Integer.MAX_VALUE; for (Size size : sizes) { int diff = Math.abs(desiredResolution - pixelCount(size)); if (diff < delta) { targetSize = size; delta = diff; } } return targetSize; } private static int pixelCount(Size size) { return size.width * size.height; } }