Is it possible to make BitmapFactory.decodeFile() respect EXIF?

前端 未结 3 408
走了就别回头了
走了就别回头了 2021-01-21 07:36

In my tests, a Bitmap created by BitmapFactory.decodeFile() doesn\'t respect EXIF header.

For example, with portrait images taken by a devices

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 07:59

    Is there a way to make BitmapFactory.decodeFile() respect EXIF and produce a correct Bitmap?

    No, sorry.

    what is the recommended pattern to handle this issue?

    Use the support library's ExifInterface to determine the desired orientation. Then, depending upon your use of the Bitmap, either rotate the view (e.g., ImageView) or rotate the Bitmap. This sample project illustrates both approaches, though I use a separate set of EXIF code, as some things that I use in that sample are not supported by the support library's ExifInterface.

提交回复
热议问题