Pableras84
Pableras84

Reputation: 1195

Issues getting Galaxy Nexus (4.2.1) Camera Megapixels with this function

I'm getting the camera megapixels with this function:

private String getCameraMegapixels(Camera cam){
        Camera.Size size;
        size = cam.getParameters().getPictureSize();
        DecimalFormat localDecimalFormat = new DecimalFormat("#.#");        
        return localDecimalFormat.format(size.width * size.height / 1000000.0D);            
    }

It works fine for front and back camera in all the phones i tested but but in Galaxy nexus. In galaxy nexus something is going wrong because i'm getting that the camera (front and back) haves 0.1 megapixels....

Is something wrong with galaxy nexus and the way to get megapixels?

PD: Galaxy Nexus Android version is 4.2.1

Upvotes: 0

Views: 317

Answers (1)

Jon Willis
Jon Willis

Reputation: 7024

If your intention is to get the maximum supported megapixels, you could simply check each of the Camera.Size in cam.getParameters().getSupportedPictureSizes() and choose the highest height*width of them.

Upvotes: 1

Related Questions