0

Hi Below is how I launch my camera. I'm always getting 320 x 240 as the image size. Any idea on how I can set such that the camera takes the image with the maximum size that the device supports?

      File photo = null;
         String FILE_NAME ="20143";
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (android.os.Environment.getExternalStorageState().equals(
        android.os.Environment.MEDIA_MOUNTED)) {
    photo = new File(android.os.Environment.getExternalStorageDirectory(), FILE_NAME);
} else {
    photo = new File(getCacheDir(), FILE_NAME);
}    
if (photo != null) {
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
    selectedImageUri = Uri.fromFile(photo);
    startActivityForResult(intent, CAMERA_PIC_REQUEST);
}
user903772
  • 1,554
  • 5
  • 32
  • 55

1 Answers1

1

To get all size that the device supports

Camera.Parameters parameters = mCamera.getParameters();
List<Camera.Size> sizes = parameters.getSupportedPictureSizes();

I'm using below method tho get best size

private Camera.Size getBestPreviewSize(int width, int height,
        Camera.Parameters parameters) {
    Camera.Size result = null;

    for (Camera.Size size : parameters.getSupportedPictureSizes()) {
        Log.d("size: ", size.width + ":" + size.height);
        if (size.width <= width && size.height <= height) {
            if (result == null) {
                result = size;
            } else {
                int resultArea = result.width * result.height;
                int newArea = size.width * size.height;

                if (newArea > resultArea) {
                    result = size;
                }
            }
        }
    }

    return (result);
}

with int width, int height is the surfaceHolder's width, height.

Toan PV
  • 201
  • 1
  • 7
  • can you post how to use in activity? – user903772 Apr 04 '13 at 05:03
  • Sorry, Im not using Camera intent in my case. Get full-size will soon cause OutOfMemory, but you can using temp file [link](http://stackoverflow.com/questions/6448856/android-camera-intent-how-to-get-full-sized-photo) – Toan PV Apr 04 '13 at 05:22