File size error

sioconcept

Active Member
Licensed User
Longtime User
Hi,

i've a problem with file. My file (a PNG) have a size of 23463. When i load the "blob" from the database and i base 64 it, then size is 23463 so the exactly same (var TheFile size is ok).

My problem is when the file is write, the size become 43 831 ! I don't know why; maybe a charset problem ?

This is my code, i load the "blob" (Base 64) and i cut it at the begin because this start by data:image/png;base64,.


B4X:
Dim TheFile= B64.DecodeStoS(PicUser.SubString(22), "UTF8") As String

File.WriteString(File.DirDefaultExternal, "av.png", TheFile)

Thanks
 

sioconcept

Active Member
Licensed User
Longtime User
I've found a good solution, so don't load directly the string to file, but create an inputstream.

PicUser is a base64 png

B4X:
Dim PidData() = B64.DecodeStoB(PicUser.SubString(22)) As Byte
Dim InputStream As InputStream
Dim BmpTemp As Bitmap

InputStream.InitializeFromBytesArray(PidData, 0, PidData.Length)
BmpTemp.Initialize2(InputStream)
InputStream.Close
ImageView.Bitmap = BmpTemp
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Upvote 0
Top