I have a code in which I call the gallery to select an image that i show in a imageview . This works fine and maintains the aspect ratio. The problem is when the image size is larger than 2048 x 2048 I am using this code when it is the case:
uriIsNowAbitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri);
//... int height = uriIsNowAbitmap.getHeight(); int width = uriIsNowAbitmap.getWidth(); if ((width>=2048)||(height>=2048)) { int newheight = height/10; // height in pixels int newwidth = width/10; // width in pixels Bitmap avatarScaled = Bitmap.createScaledBitmap(uriIsNowAbitmap, newwidth, newheight, true); previewNewAvatar.setImageBitmap(avatarScaled);
}
also works correctly, but with a problem. The images are not of the type shown rotated landscape
to try to explain, I put this example. This is the picture of the gallery:
when I select the picture and assign it to the imageview is shown rotated:
I do not understand why. I've tried a thousand ways and have read a lot of information about resize, i have read threads and sample code for this website (Android: high quality image resizing / scaling) and and many more... but nothing helps. The intention is to show in this way ...make it with photoshop :)
I appreciate any help, took many hours trying to fix it
Regards