The following code works perfectly in Desktop. But on Android it always returns NIL in Picture. I’ve noticed that the data doesn’t arrive exactly the same as in Desktop, some characters change or are missing.
var socket As New URLConnection
var url As String = “myurl/mypicture.png”
var data As String
data = socket.SendSync(“GET”, url, 10) ’ using synchronous GET
If socket.HTTPStatusCode = 200 Then ’ OK
’ Picture.FromData creates a new picture from raw binary data
var p As Picture
var rawData As String
rawData = DecodeBase64(data)
p = Picture.FromData(rawData)
ImageViewer1.Image = p
ImageViewer1.Refresh
Else ’ errors, redirects, etc.
MessageBox("Error : " + socket.HTTPStatusCode.ToString)
Maybe it’s being compressed by the server? Is the broken picture file the correct length? Are the first two bytes 1F8B (the magic number for gzip compressed data)?
The same picture with the same URL in the same server with the same code work perfect in desktop project, the problem is in Android project, always return NIL on picture.FromData…