Cornelius Smit Member Licensed User Dec 18, 2018 #1 Does anyone have a working example on how to use bytearray to create a bitmap the string was created from base64 description.
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 Dec 18, 2018 #2 Step 1: convert the image to base 64 encoding. I did it with B4J: Code: Copy 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: Code: Copy 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) Upvote 0
Step 1: convert the image to base 64 encoding. I did it with B4J: Code: Copy 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: Code: Copy 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)