0

I just looked at similar question in Stackoverflow, but haven't found an solution for it.

Everytime I try to capture a photo with my android app, it returns as a result a bitmap photo of an resolution of 240x360 px, although the camera is about 8 Megapixel.

So where is the mistake in my programmed code: (look at this screenshot)

    private static final int TAKE_PHOTO_CODE = 1;

    private static void takePhoto(){
        final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(thisOne.getBaseContext())) );
        thisOne.startActivityForResult(intent, TAKE_PHOTO_CODE);
    }

    private static File getTempFile(Context context){
        //it will return /sdcard/image.tmp
        final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName() );
        if(!path.exists()){
            path.mkdir();
        }
        return new File(path, "image.tmp");
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            switch(requestCode){
                case TAKE_PHOTO_CODE:
                    final File file = getTempFile(this);
                    try {
                        Bitmap captureBmp = MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.fromFile(file));
                        int a = captureBmp.getHeight(); // RESULT 240
                        int b = captureBmp.getWidth(); // RESULT 360
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    break;
            }
        }
    }

Thanks for your help

fadden
  • 51,356
  • 5
  • 116
  • 166
Alex Schled
  • 9
  • 1
  • 4
  • 1
    Have you tried using `BitmapFactory` to load in the image? Have you tried looking at the image file from somewhere other than inside your app? – CommonsWare Sep 29 '15 at 19:28
  • 1
    See http://stackoverflow.com/a/10382217/192373: `MediaStore.Images.Media.getBitmap()` only gives you a thumbnail; the full-sized image should be loaded from the file whose path may be found from `MediaStore.Images.Media.DATA` column. – Alex Cohn Sep 29 '15 at 20:05

1 Answers1

0

Use this. Get a list of the supported sizes. Loop through it to find the biggest resolution.

Parameters params = camera.getParameters();
 List<Size> sizes = params.getSupportedPictureSizes();
                Camera.Size size = sizes.get(0);
                for(int i=0;i<sizes.size();i++)
                {
                    if(sizes.get(i).width > size.width)
                        size = sizes.get(i);
                }
Prasanth Louis
  • 4,658
  • 2
  • 34
  • 47