I am developing an Android application in 2.2, which uses Camera. Now Can anyone tell me that "Is it possible to programmatically determine the Camera Resolution in Megapixels in Android"
5 Answers
if you've got the camera object, try:
android.hardware.Camera.Parameters parameters = camera.getParameters();
android.hardware.Camera.Size size = parameters.getPictureSize();
int height = size.height;
int width = size.width;

- 189
- 3
-
But these are the picutre width and height. But actually I need the Camera resolution, in MegaPixels, from which I want to process images accordingly. – YuDroid Aug 05 '11 at 07:20
-
4YuDroid, use the answer provided by @wAroXxX, which gives you the height and width of the pictures that the camera will output, then use the equation given by PravinCG "Resolution in pixel = width X height" Which gives you Resolution in Pixels and divide that by 1,024,000 . This will give you your resolution in MegaPixels. So: Megapixels = (width * Height)/1024000; – TChadwick Oct 18 '12 at 15:09
-
Dear programmers 1 megapixel = 1 000 000 pixels not 1 024 000. Copy/paste without verification is the root of all evil – Osagui Aghedo Sep 17 '20 at 17:16
What does image resolution mean?
Resolution refers to the number of pixels in an image. Resolution is sometimes identified by the width and height of the image as well as the total number of pixels in the image. For example, an image that is 2048 pixels wide and 1536 pixels high (2048X1536) contains (multiply) 3,145,728 pixels (or 3.1 Megapixels). You could call it a 2048X1536 or a 3.1 Megapixel image. As the megapixels in the pickup device in your camera increase so does the possible maximum size image you can produce. This means that a 5 megapixel camera is capable of capturing a larger image than a 3 megapixel camera.
Example: 1936 x 1552 / 1024000 = 3 Mega Pixels

- 939
- 3
- 15
- 31
-
Hi @Heather McVay, My Mobile Phone model is Samsung galaxy star pro GT-S7262. and this mobile specification details shows Samsung [website](http://www.samsung.com/in/consumer/mobile-phone/mobile-phone/smartphone/GT-S7262MKAINU-spec?subsubtype=android-mobiles)/user manual/purchased box having printed only 2MP, but when i am getting max resolution of this mobile is 2048x1536. so it gives approximately 3.072MP by following the above link/ above code. so finally i said that above procedure is Not always gives correct result. please help me to find out correct megapixes in android mobile. – challa sathish kumar Feb 26 '14 at 11:12
-
Micromax Bolt A35 device specification shows 2MP(Mega Pixel) but it gives 2592 x 1936 resolution picture. by using above procedure ((2592x1936)/102400)= approximate 5MP it wrong result. So please help me to find out exact megapixels of given android mobile device. please refer my detailed question.[How to find exact camera megapixels in android mobile](http://stackoverflow.com/questions/22032036/how-to-find-exact-camera-megapixels-in-android-mobile). – challa sathish kumar Feb 26 '14 at 11:13
-
Dear programmers 1 megapixel = 1 000 000 pixels not 1 024 000. Copy/paste without verification is the root of all evil – Osagui Aghedo Sep 17 '20 at 17:15
Try this
public float getBackCameraResolutionInMp()
{
int noOfCameras = Camera.getNumberOfCameras();
float maxResolution = -1;
long pixelCount = -1;
for (int i = 0;i < noOfCameras;i++)
{
Camera.CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK)
{
Camera camera = Camera.open(i);;
Camera.Parameters cameraParams = camera.getParameters();
for (int j = 0;j < cameraParams.getSupportedPictureSizes().size();j++)
{
long pixelCountTemp = cameraParams.getSupportedPictureSizes().get(j).width * cameraParams.getSupportedPictureSizes().get(j).height; // Just changed i to j in this loop
if (pixelCountTemp > pixelCount)
{
pixelCount = pixelCountTemp;
maxResolution = ((float)pixelCountTemp) / (1024000.0f);
}
}
camera.release();
}
}
return maxResolution;
}
Add this permission in android manifest
<uses-permission android:name="android.permission.CAMERA" />

- 3
- 2

- 320
- 2
- 9
You can you this to get the list of supported sizes. getSupportedSizes()
The highest size would give you the camera resoultion in pixels.
EDIT: Just in case you do not know.
Resolution in pixel = width X height

- 7,688
- 3
- 30
- 55
Yes, that way works to me. One more note here, getPictureSize() will return a list of supported size with different heights and widths. To calculate the resolution in pixel of device's camera, please get the biggest height & width from the size list.

- 69
- 1
- 2
- 9