At the moment I am attempting to set my camera on my Motorola Droid phone to take an image that matches the size of my screen (854 x 480 pixels), and I am attempting to accomplish via the parameters for the camera as such:
Camera.Parameters parameters = this.mCamera.getParameters();
Log.i(TAG, "CAMERA SIZE: (" + this.mCameraView.getWidth() + ", " + this.mCameraView.getHeight() + ")");
parameters.setPictureSize(this.mCameraView.getWidth(), this.mCameraView.getHeight());
this.mCamera.setParameters(parameters);
this.mCamera.takePicture(null, null, this);
I have my activity implement the Camera.PictureCallback method of onPictureTaken (excluding log calls), so when the takePicture method is called it runs this method:
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Bitmap image = BitmapFactory.decodeByteArray(data, 0, data.length);
//Size imageSize = camera.getParameters().getPictureSize();
//image = Bitmap.createBitmap(image, 0, 0, imageSize.width, imageSize.height);
this.mCameraView.setBackgroundDrawable(new BitmapDrawable(image));
}
For some reason though, my camera is taking pictures in 1280 x 960. Is this some sort of minimum size the camera can capture an image in? From log calls I can see that the Camera's parameters are still set to have a picture size of 854 x 480, but image keeps coming out as 1280 x 960. Am I decoding the image incorrectly, am I setting the camera's parameters incorrectly, or am I doing something else wrong?
Thanks in advance for any help you can give!
Regards, celestialorb.
Yes there are methods provided to get the picture sizes supported by camera. The method the paramters class of camera which provides the supported picture sizes by camera is getSupportedPictureSizes(); Using this method, you can get the supported size by camera. The code snippet would look like this:-
Camera camera = Camera.open();
Parameters params = camera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();
I hope this will help you.
Thanks Nawab
I have found the answer, apparently my own screen resolution is not a supported size for the camera. I was not aware of the camera only being able to support certain sizes as I am programming with the 1.6 SDK.
Is there any way to retrieve the supported sizes of the camera for 1.5/1.6?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With