Please note that I don’t respond to questions on the youtube channel but for those that require help I provide paid consultancy services here

It has been found in a number of devices that the orientation of the captured image is wrong.
With the captured image being displayed often with a 90 degree offset.

This is mainly on non-nexus devices and I have been able to reproduce this behaviour on a Samsung Note 4 device.

This android tutorial will show one method on how to rotate the image correctly after it has been captured from the camera application.

In this tutorial we will cover:
– Creating the exifinterface
– Getting the image orientation from the exifinterface
– Creating a matrix
– How to rotate a matrix
– Creating a new bitmap using the offset provided by the matrix

API’s covered
– ExifInterface
– ExifInterface.getAttributeInt
– Matrix
– Matrix.setRotate
– Bitmap.createBitmap
– ImageView.setImageBitmap

For much more information checkout
Website –
Twitter –
Facebook –
Google+ –
Pinterest –

The previous tutorials were aimed at beginners to android but over time have been getting more complex as the original camera_intent app has developed.
This tutorial series is more aimed towards the intermediate developers thought for those who have been following the previous tutorial series, feel free to watch this android performance series.

Android studio (1.4.2) is the editor of choice (IDE) for this tutorial series.

This tutorial series is the start of what I expect to be many so I encourage comments and feedback to improve the quality and viewing experience.

Nguồn:https://u-os.org/

Xem Thêm Bài Viết Khác:https://u-os.org/cong-nghe

Author

31 Comments

  1. franklin joney Reply

    ExifInterface always returns zero in samsung S7 , need some help..

  2. The exotic Scholar Reply

    What r u even showing .its complicated to common one

  3. khalid alsaleh Reply

    I have a problem is that i have a method for exifinterface always returns zero

  4. NamJin Shipper's Club Reply

    can you tell me how to capture one image in 500ms please i need it so much

  5. Rodrigo García Reply

    …but it works fine with me, let me show you… Oh! Loled!

  6. JUAN PABLO ROJAS MARÍN Reply

    You´re such a good programmer, thanks a lot!

  7. John Poulikidis Reply

    hi ! i save the uri in sqlite , then i take the uri from sqlite and use in imageView.setImageUri(uri)! i need to rotate after that the image and i don't know how to do this ! i try with your code put … 🙁 ! can you help me ;

  8. Trần Tùng Reply

    the code return for me picture very small.i search in google, it tell because bitmap type .can you help me

  9. Thank you! Thank you!!! You really saved my life! Ive been searching almost 1 week to solved dis problem. The stackoverflow for this problem didnt solved for my sony xperia device. But urs one solved it! Thanks alot again!

  10. osman kayatas Reply

    How to get or set mImageFileLocation ? could you shre the code please ?

  11. Sumit Thorat Reply

    Worked like a charm but, I had to make my own modifications to cater the needs of my application. Thanks 😀

  12. Mouna Rojbi Reply

    Hi,
    I want ti Know how to create a photo from several.
    I want to put the photos next to each other.

  13. Duško Bajić Reply

    I believe that 9:54 is NullPointerException waiting to happen in the case of exception above.

  14. I have a button that pulls up my gallary for me to select an image. How would I go about doing the same thing with the EXIF?

  15. Ahmad Alkhateeb Reply

    Really Thanks for these awesome tutorials,
    But please where we can find source code , it seems there are only samples in github !

  16. Moti Bartov's Channel Reply

    Great Thanks!
    However, it is recommended to add 270 degrees check that's for the front camera.

  17. Réda Youssoufi Reply

    Hi Nige 🙂 !! This function don't work for faceCam. How can I do to rotate selfi Image? Thank you so much

  18. Kotlíík Kotlííček Reply

    Plse how to make an application that would not revolve?

  19. In my code creatBitmap said connot resolve method problem and there is no matrix.setRotate ……

  20. Tommy Dwi Putranto Reply

    hi , can you share your source code in github ?

Write A Comment