Android : How to get real Camera max Megapixels of a device?

on Sunday, August 31, 2014


I'm trying to find the REAL Camera max Megapixels of a device and i tested some code found on stackoverflow and google with cam.getParameters().getSupportedPictureSizes();, but the code does not work well on all the devices.


For example on NEXUS 5 it works fine and tells that the device haves 8Mpx, but in BQ Aquaris E5 FHD with KitKat 4.4.2 it does not work well and tells that the device haves 19 Mpx (it haves 13 Mpx...)


The problem in Bq Aquaris is that the code obtains all the supported picture sizes, and the most huge value is 5888x3312, that value means 19.5 mpx, but really this device does not support 19.5 mpx, so i dont understand why 5888x3312 is returend by getSupportedPictureSizes() and i dont know how i must ignore non real values like that value.


This is the code that does not work properly:



DecimalFormat localDecimalFormat = new DecimalFormat("#.#", symbols);
String sizeInMegapixel=getString(R.string.not_available);
if(cam!=null){
Camera.Parameters camParams=cam.getParameters();
List<Size> list = cam.getParameters().getSupportedPictureSizes();
Camera.Size size;
Size maxSize=list.get(0);
int aux;
int maxAux=0;

for (int i=0;i<list.size();i++){
size=list.get(i);
aux = size.width*size.height;
if (aux>maxAux){
maxAux=aux;
maxSize=size;
}
}
sizeInMegapixel=localDecimalFormat.format((maxSize.width*maxSize.height)/1000000.0D);
}

0 comments:

Post a Comment