5

I want to get an image with a device higher then android kitkat. Currently I use the filedescriptor and parcelfiledescriptor to get the image. I get the image succesfully, but rotated. As the image is stored on google drive I can't use the inputstream directly. How can I solve this? (I know image data is usually stored in exif but if I try to get exif data the rotation is always 0) I've also tried using the lib: https://github.com/coomar2841/image-chooser-library but I get the same issue here.

           ParcelFileDescriptor parcelFileDescriptor;
        try {
            parcelFileDescriptor = activity.getContentResolver().openFileDescriptor(selectedImage, "r");

            FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();

            Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
            image = ExifUtil.rotateBitmap(selectedImagePath, image);
            parcelFileDescriptor.close();
            if (cropCircle) {
                imageView.setImageBitmap(ImageUtils.cutCircle(image));
            } else {
                imageView.setImageBitmap(image);
            }
            return image;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
jobbert
  • 3,297
  • 27
  • 43

0 Answers0