Save two images, bitmap and uri

0

Good evening, I have an application that takes pictures and brings them from the gallery, I can take the photo and I save it in a URI as well as the image I bring from the gallery, now my question is, how do I create a bitmap with the same image but compressed and also save it in another direction, then when I take them to the server I take them separately, then I carry the image in full size and the compressed image

This I want to do to achieve what is called thumbnail, then when loading the photos first charge the first and then charge the full size

 if (requestCode == 1 && resultCode == Activity.RESULT_OK) {

            mImageUri = data.getData();

            CropImage.activity(mImageUri)
                    .setGuidelines(CropImageView.Guidelines.ON)
                    .setAspectRatio(1, 1)
                    .start(getContext(), this);

            mUploadBtn.setImageURI(mImageUri);
        }

        if (requestCode == 2) {

            mImageUri = data.getData();

            CropImage.activity(mImageUri)
                    .setGuidelines(CropImageView.Guidelines.ON)
                    .setAspectRatio(1, 1)
                    .start(getContext(), this);

            mUploadBtn.setImageURI(mImageUri);
        }

        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {

            CropImage.ActivityResult result = CropImage.getActivityResult(data);

            if (resultCode == Activity.RESULT_OK) {

                mImageUri = result.getUri();

                mUploadBtn.setImageURI(mImageUri);
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {

                Exception error = result.getError();
            }
        }

    }

Here I save the image taken from both the camera and the gallery in my mImageUri, now, I want to save the same image in a bitmap but compressed by 90%, that is to say that instead of having an mImageUri, I should also have something Call for example mImageCompress

Thanks

    
asked by Armando Barreda 14.10.2016 в 02:06
source

1 answer

0

For the Thumbnails you have 2 strategies:

  • Save both versions of the image in storage. In this way what you would do is upload the original image as well as a compressed and cropped version (which would be done at the time of uploading the image). With this strategy you simply show the thumbnails in the list and when you select an item just there you download the full size image.
  • This option is the most performant since you only download full size photos when they are really required but you have requests and redundant space for the thumbnails.

  • Save only the full size images: With this strategy you save the images in high resolution and the downloads to show the thumbnails in the list (which would consist of an imageview in which apply an algorithm to compress the live image ).
  • This strategy is simpler but means that high-resolution photos will be downloaded frequently, increasing data consumption significantly.

        
    answered by 30.05.2017 в 19:52