0

I read about this in several forum questions. But always, people end up using the method "Bitmap createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter)", but I can not apply this method because, when dealing with large images, it fails with a message of outofmemory.

I want to know how I can resize a large image already taken. I've readed the android developer section of large bitmaps but I haven't been able to implement it.

I'm using the next code to capture a photo.

public void openTakePicture() {

        String date = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss").format(new Date());

        photoname = "pic_" + date + ".jpg";

        // Create an output file.
        file = new File(Environment.getExternalStorageDirectory(), photoname);
        outputFileUri = Uri.fromFile(file);

        // Generate the Intent.
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

        // Launch the camera app.
        startActivityForResult(intent, TAKE_PICTURE);

    }

Thanks for your comments

Víctor Martín
  • 3,352
  • 7
  • 48
  • 94

1 Answers1

1

Depending on your needs you could capture a smaller picture and then manipulate it. I was using something similar to the below but ran into issues where some cameras didn't support the setPictureSize so I ended up using the scaled bitmap approach.

You may need to test to see if the camera supports your desired size before calling setPictureSize.

parameters.setPictureFormat(ImageFormat.JPEG);
parameters.setPictureSize(1600, 1200);
parameters.setJpegQuality(30);
mCamera.setParameters(parameters);
Gravitoid
  • 1,294
  • 1
  • 20
  • 20