Solution to the problem that the pictures obtained by some Android mobile phones are rotated after taking pictures

After calling the photographing function of Android system, the photos taken by Samsung mobile phone are rotated by 90 degrees, and the photos taken horizontally become vertical, and the photos taken vertically become horizontal. Other brands of mobile phones are normal. This strange thing happened to Samsung.

In terms of Android adaptation, I always thought that domestic Xiaomi mobile phones were wonderful enough, and there were even more wonderful results! What do you say you have nothing to do with rotating photos? I really can't guess what its purpose is. It's just causing trouble for developers!

The solution is to get the rotation angle of the photo after taking the photo, and then rotate it back.

Specific ideas: 1. First, when calling the photographing method, save the original photo after photographing and get the original path. (photobitmaputils is a tool class written by myself)

2. In the callback method onactivityresult() returned by the camera, repair the rotated picture and obtain the repaired picture path. With this path, it can be displayed

Photobitmaputils class:

When calling the method of repairing the angle of the picture, it should be noted that the pixels of the mobile phone are getting larger and larger. After taking a picture, there is nearly 10m, so we need to compress the picture. Otherwise, you will wait a long time when saving the picture, and the screen will be dark for a while. Reference document 1 reference document 2

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>