get Camera Proper Preview Size - Android Camera

Android examples for Camera:Camera Preview

Description

get Camera Proper Preview Size

Demo Code


//package com.java2s;
import java.util.List;

import android.hardware.Camera;
import android.hardware.Camera.Size;

public class Main {
    public static Camera.Size getProperPreviewSize(
            Camera.Parameters parametrs) {
        List<Camera.Size> sizesList = parametrs.getSupportedPreviewSizes();

        Size properSize = sizesList.get(0);

        if (sizesList.size() > 1) {
            for (int i = 1; i < sizesList.size(); i++) {
                if (sizesList.get(i).width > properSize.width
                        && sizesList.get(i).height > properSize.height) {
                    properSize = sizesList.get(i);
                }/*from   w  w w  .  ja va 2 s . c  om*/
            }
        }

        return properSize;
    }
}

Related Tutorials