简体   繁体   中英

How to convert a bitmap to an image resource - Android

I am trying to set an image to a custom View, but my problem is that this custom view only accept the setImageResource() method.

My image files are stored locally inside the phone, so I use a code to encode them to bitmap.

Can I use the setImageResource() function to display bitmap images in some way?

No, sorry. The custom view would need to be modified to support other image sources.

For the custom view you need to modify the support, once you have do it, then If it is encoded on Base64, you can transform that content to a image

val decodedString = Base64.decode(document.thumbnailImage, Base64.DEFAULT)
val decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.size)
imageView.setImageBitmap(decodedByte)

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