Question

I've to work with camera for the first time on the Android platform. My goal is to be able to snap an image with an optimum resolution and then transfer it over the network with the least level of compression.

The function "getSupportedPictureSizes" gives me the resolutions supported by the camera. But do I apply my desired resolution on the preview object (android.view.SurfaceView) or on the camera parameter object (android.hardware.Camera.Parameters)?

Apologies in advance if the question doesn't make sense but I'm confused!

Was it helpful?

Solution

But do I apply my desired resolution on the preview object (android.view.SurfaceView) or on the camera parameter object (android.hardware.Camera.Parameters)?

getSupportedPictureSizes() is for pictures. You update the Camera.Parameters via setPictureSize() to indicate what Camera.Size you want for the actual picture taken via takePicture().

getSupportedPreviewSizes() is for preview frames. You update the Camera.Parameters via setPreviewSize() to indicate what Camera.Size you want for the preview frames. You probably also want to set up your Surface to be the same size, or at least the same aspect ratio, so the image does not get stretched or squished.

And, FWIW, you may find my CWAC-Camera library easier to use than the native Camera API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top