B4J Question [BANano] [SOLVED] How can I get a base64 string for an asset image file?

tchart

Well-Known Member
Licensed User
Mash

I use StringUtils for this;

B4X:
Dim s As StringUtils
         
ResultBytes = req.bytes  'You would need to read the bytes of the image file
Result = s.EncodeBase64(ResultBytes)

You just need to wrap it like so to use as an image;

B4X:
Preview = $"<img src="data:image/png;base64,"$ & Result& $"" alt="Picture" />"$
 
Upvote 0
Top