How to remove the frame of a photo taken with android studio

1

The problem I have is that when you take a photo from my application and I proceed to save it, it is stored with a frame on the sides.

I wanted to know how I can delete this framework.

I leave my code

private void openCameraIntent() {
    Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (pictureIntent.resolveActivity(getPackageManager()) != null) {

        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        Uri photoUri = FileProvider.getUriForFile(this, getPackageName() + ".provider", photoFile);
        pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
        ivimagen.setImageURI(Uri.parse(imageFilePath));
        ivimagen.buildDrawingCache();
        startActivityForResult(pictureIntent, 1);
    }
}

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    File image = File.createTempFile(
            imageFileName,  /* prefix */
            ".jpg",         /* suffix */
            storageDir      /* directory */
    );

    // Save a file: path for use with ACTION_VIEW intents
    imageFilePath = image.getAbsolutePath();
    return image;
}

    
asked by Samuel Alcivar 29.08.2018 в 22:02
source

1 answer

0

I can assure you that what you are saying is not related to the code, in fact your camera is configured to take the image with that aspect

Usually the camera is set to look like 16: 9 , in your case it is possibly set to 4: 3 as the image looks almost square.

The aspect 16: 9 has a rectangular appearance, if the image is displayed on your device with horizontal orientation, the image will be shown with spaces at the ends:

But in reality the image is saved correctly, the black space is the background.

    
answered by 30.08.2018 / 01:03
source