Forme
Forme

Reputation: 301

Set the maximum resolution for the camera

I get a list of extensions and try to compare the first and last values:

Camera.Parameters params = camera.getParameters();
List sizes = params.getSupportedPictureSizes();
int wc1=0, wc2 = 0, hc1 = 0, hc2 = 0, wf = 0, hf=0;
Camera.Size result = null;
for (int i=0;i<sizes.size();i++){
    result = (Size) sizes.get(i);
    if (i==0){
         wc1=result.width; hc1=result.height;
    } 
    if (i==sizes.size()){
         wc2=result.width; hc2=result.height;
    } 
    if (wc1 > wc2) {wf=wc1; hf=hc1;} 
    if (wc2 > wc1) {wf=wc2; hf=hc2;}         
}
params.setPictureSize(wf, hf);

Not determined the expression:

i==sizes.size()

How to set the last item in the list? Thank you advance

Upvotes: 0

Views: 498

Answers (1)

Jitender Dev
Jitender Dev

Reputation: 6925

Do like this

List sizes = params.getSupportedPictureSizes();

// last item present in list is size of list minus 1

sizes.get(sizes.size()-1);

and your expression

if (i==(sizes.size()-1)){
         wc2=result.width; hc2=result.height;
    } 

Upvotes: 1

Related Questions