简体   繁体   中英

Is it necessary to convert an image uri into a file or bitmap?

Is it necessary to convert an image uri into a file or a bitmap before displaying to imageview? Why all the tutorials around are doing that when we can directly display using the uri? All are showing how we do that but no one is talking about the why.

Is not necessary as the ImageView performs the decoding for you.

But, must be taken into consideration if the image size is too large, as it could produce an OOM . In addition , is not efficient to load bitmaps which are larger than the ImageView canvas, ( unless the ImageView supplies custom funcitonalities such as pinch-to-zoom ).

When the image is too large, or you wish to control its size for a better memory optimization, it must be decoded first into a Bitmap with reasonable metrics:

https://developer.android.com/topic/performance/graphics/load-bitmap

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM