get Camera Best Size On With - Android Camera

Android examples for Camera:Camera Size

Description

get Camera Best Size On With

Demo Code


//package com.java2s;

import java.util.List;
import android.hardware.Camera.Size;

public class Main {
    private static Size getBestSizeOnWith(int width,
            List<Size> supportedSizes) {
        double lastDiff = Double.MAX_VALUE;
        Size bestSize = null;//from  ww  w. ja  v a  2 s .  c  o m

        for (Size size : supportedSizes) {

            double diff = Math.abs(width - size.width);
            if (diff < lastDiff) {
                lastDiff = diff;
                bestSize = size;
            }
        }

        return bestSize;
    }
}

Related Tutorials