get Henry Optimal Size - Android android.hardware

Android examples for android.hardware:Camera Size

Description

get Henry Optimal Size

Demo Code


//package com.java2s;

import java.util.List;

import android.hardware.Camera;

public class Main {
    public static Camera.Size getHenryOptimalSize(List<Camera.Size> sizes,
            int w, int h, int ratio) {
        Camera.Size optimalSize = null;/*from ww w.  j  av  a2s  . com*/

        for (Camera.Size mCamera : sizes) {
            if ((double) mCamera.width / (double) mCamera.height == (double) 4
                    / (double) 3) {
                if (optimalSize == null) {
                    optimalSize = mCamera;
                }

                if ((optimalSize.height > mCamera.height)
                        && (mCamera.height > h))
                    optimalSize = mCamera;
            }
        }
        return optimalSize;
    }
}

Related Tutorials