Android Camera Intent Image Quality
I'm making an android application that uses the 开发者_C百科camera by using the built in one as an intent. I'm doing some analysis on the photo on a pixel by pixel basis. My wildfire returns 79000 pixels in a normal photo, this is making the analysis a little slow.
Is there any way to set the quality/resolution of the camera or image returned when using intents? I've had a look around on Google and the api and haven't come up with much. Anyone know if this is even possible or know of some other way to degrade the image resolution?
Any help greatly appreciated.
Why use the built in Appliction though the intent and not an application you'll write yourself by using the API ? I have seen various problems when using the camera this way; after all, if you want full control you shouldn't be using the intent. There are lots of working examples for taking photos through the API.
So, when using the camera through the API you may use the setParameters method of the Camera class to pass a CameraParameters object to your camera object and change various parameters.
The CameraParameters class contains a setPictureSize(int , int) method which you may use to change the size of your picture. You can use the getSupportedPictureSizes() method of CameraParameters to find out which picture sizes your device supports and use the one that fits you.
List<Size> sizes = mCamera.getParameters().getSupportedPictureSizes();
for (Size size : sizes) {
// Do something, e.g. :
menu.add(0, 1, 1, size.width + "x" + size.height);
}
Also, I see that you may set the format of your picture as NV21. This is a raw format and you can easily subsample the pixels of the returned image yourself (take a single pixel as the average of every 4 pixels so you will reduce both your image width and height by two) !
精彩评论