I'm facing a weird situation concerning picture size and aspect ratio but maybe it will be obvious for some, I hope.
I have a RecyclerView
in which I insert picture (and video), the width of picture is forced
(maxWidth/2).
What I want to do is to keep the original aspect ratio and set the height of the picture according the width value. Then I had to retrieve the initial size of picture from the user private gallery :
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file, options);
fileHeight = options.outHeight;
fileWidth = options.outWidth;
I calculated the factor between width and height, but I found that it could not work when the picture sizes were inverted. I made some tests on several camera and some take picture for instance in 720x1280 and other 1280x720 resolution whereas the picture is exactly the same.
Then I tried to inverted the calcul factor according the initial sizes but it's not working because of picture format (landscape...). This is the same thing with video.
How can I achieve this ?