ImageView, Picture load from Internet?

hasexxl1988

Active Member
Licensed User
Longtime User
Hello,
I wanted to ask if I can help those who may have already looked at HTTP examples, but does not continue anyway. Perhaps a solution-oriented whoever. Here is my code, what does not. : (

ImageView1.Bitmap = LoadBitmap ("http://img24.imageshack.us/i/","d3100.jpg")
 

NJDude

Expert
Licensed User
Longtime User
You cannot do that, the syntax is:
B4X:
LoadBitmap (Dir As String, FileName As String) As Bitmap

To do what you want you have to download the picture and then load it to the ImageView
 
Upvote 0

netchicken

Active Member
Licensed User
Longtime User
here is some code I have been working on, in the link below this is only part of the code.
'dim stuff
B4X:
 Dim hcimage As HttpClient 'download the image
       Dim reqimage As HttpRequest
get the image - pic being image name
B4X:
 Dim imagepath As String
imagepath = "http://m.metservice.com/sites/all/themes/mobile/images/wx-icons/"& pic
reqimage.InitializeGet(imagepath)
hcimage.Execute(reqimage, 1)

save it
B4X:
 Sub hcimage_ResponseSuccess(Response As HttpResponse, TaskId As Int)

  Response.GetAsynchronously("ImageResponse", _   
  File.OpenOutput(File.DirInternalCache, pic, False), True, TaskId)
End Sub

'load image auto
B4X:
 Sub ImageResponse_StreamFinish (Success As Boolean, TaskId As Int)
    If Success = False Then
        Msgbox(LastException.Message, "Error")
        Return
    End If
    imgtemp.Bitmap = LoadBitmap(File.DirInternalCache, pic)
End Sub




'load the image manually
B4X:
 If File.Exists(File.DirInternalCache, pic) Then
'if so then load it
imgtemp.Bitmap = LoadBitmap(File.DirInternalCache, pic)
 
Upvote 0
Top