get Camera Best Sizes On Ratio And Tolerance - Android Camera

Android examples for Camera:Camera Size

Description

get Camera Best Sizes On Ratio And Tolerance

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;
import android.hardware.Camera.Size;

public class Main {
    private static List<Size> getBestSizesOnRatioAndTolerance(
            double sourceRatio, List<Size> supportedSizes, double tolerance) {
        List<Size> bestSizes = new ArrayList<Size>();

        for (Size size : supportedSizes) {

            double supportedRatio = (double) size.width / size.height;

            if (Math.abs(sourceRatio - supportedRatio) < tolerance) {
                bestSizes.add(size);// w w w  . ja v  a  2 s  . co m
            }
        }

        return bestSizes;
    }
}

Related Tutorials