1

I want to take an image with the camera and save it into pictures folder... the only thing that I cannot resolve is why my image is saved in a small size...

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, TAKE_PICTURE);

protected void onActivityResult(int requestCode, int resultCode, Intent imageReturned) {
    super.onActivityResult(requestCode, resultCode, imageReturned);

    switch(requestCode) {
        case TAKE_PICTURE:
            if(resultCode == RESULT_OK)
            { 
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);                  

                File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+ File.separator + "test3.png");
                try {
                    f.createNewFile();
                    //write the bytes in file
                     FileOutputStream fo = new FileOutputStream(f);
                     fo.write(bytes.toByteArray());
                     fo.flush();
                     // remember close de FileOutput
                     fo.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }    
            }
    }
}
Shivam Kumar
  • 1,892
  • 2
  • 21
  • 33
Tobiel
  • 1,543
  • 12
  • 19
  • 1
    Possible duplicate of http://stackoverflow.com/questions/1910608/android-action-image-capture-intent/1932268#1932268 – SeanPONeil Feb 04 '13 at 21:12

1 Answers1

9

You should consider reading the documentation:

http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE

It always give you a smaller image unless you set it to give you full sized:

Directly from the Dev Site

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.

JoxTraex
  • 13,423
  • 6
  • 32
  • 45