iOS Question InitializeFromBytesArray

Cornelius Smit

Member
Licensed User
Does anyone have a working example on how to use bytearray to create a bitmap
the string was created from base64 description.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Step 1: convert the image to base 64 encoding. I did it with B4J:
B4X:
Dim su As StringUtils
Dim b() As Byte = File.ReadBytes("C:\Users\H\Downloads\111789.png", "")
File.WriteString("C:\Users\H\Downloads", "img.txt", su.EncodeBase64(b))

Step 2: decode it:
B4X:
Dim su As StringUtils
Dim b() As Byte = su.DecodeBase64(File.ReadString(File.DirAssets, "img.txt"))
Dim img As Bitmap
Dim in As InputStream
in.InitializeFromBytesArray(b, 0, b.Length)
img.Initialize2(in)

SS-2018-12-18_09.13.59.png
 
Upvote 0
Top