1

I have that app that takes a picture and stores it to the SD card, however every picture I take it extremely compressed and very low quality. I compress it with full quality so I'm not sure why it's doing this. Any suggestions? Here is the code:

protected void takePhoto()
{
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(intent, 0); 
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    super.onActivityResult(requestCode, resultCode, data);
    currPhoto = (ImageView) findViewById(R.id.imageView1);

    if (requestCode== 0 && resultCode == Activity.RESULT_OK){
        Bitmap x = (Bitmap) data.getExtras().get("data");
        currPhoto.setImageBitmap(x);
        ContentValues values = new ContentValues();
        values.put(Images.Media.MIME_TYPE, "image/jpeg");
        Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
        OutputStream outstream;
        try {
            outstream = getContentResolver().openOutputStream(uri);

        x.compress(Bitmap.CompressFormat.JPEG, 90, outstream);
        outstream.close();
        } catch (FileNotFoundException e) {
            //
        }catch (IOException e){
            //
        }
    }
}

Edit: In fact it appears it only saves the thumbnail to SD.

example

RyPope
  • 2,645
  • 27
  • 51

1 Answers1

1

From the documentation:

public static final String ACTION_IMAGE_CAPTURE

Added in API level 3 Standard Intent action that can be sent to have the camera application capture an image and return it.

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.

Stephan Branczyk
  • 9,363
  • 2
  • 33
  • 49
  • Awesome thank you, this helped me understand it. For anyone else with the same problem [this link](http://stackoverflow.com/questions/9976817/take-picture-with-camera-intent-and-save-to-file) was the code I needed. – RyPope Apr 07 '13 at 01:40