B4A Library Load imageview bitmap from Url without download

Direct display of any image from its url in an imageview:

Methods:
imageLoadFromUrl: bring the bitmap from url
urlSetBitmap: load the image in an image view with the same original aspect ratio.

Attachments: library
and here is an example:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Dim iv As ImageView
    Dim imgload As imageLoadFromUrl
    Dim urlInput As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    urlInput.Initialize("urlInput")
    Activity.AddView(urlInput,0,0,100%x, 40dip)
    
    iv.Initialize("iv")
    iv.Gravity=Gravity.fill
    Activity.AddView(iv, 0, 10%x, -1, 75%y)
    
    
    imgload.Initialize
    
End Sub
Private Sub urlInput_EnterPressed
    Dim bm As Bitmap=imgload.imageLoadFromUrl(urlInput.Text)
    imgload.urlSetBitmap(iv, bm)

End Sub
 

Attachments

  • imgloadFromUrl.jar
    1.8 KB · Views: 74
  • imgloadFromUrl.xml
    1.7 KB · Views: 64

jkhazraji

Active Member
Licensed User
Longtime User
Load imageview bitmap from Url without download

I think you'll find it is still with download but just not by your code.



But I agree it's nice to have the messy detail taken care of by somebody else. 🍻
Although I did not get the point of your words, until then it needs not to be meaner to be clearer.
 
Last edited:

emexes

Expert
Licensed User
I did not get the point of your words

When you say it displays an image from a URL without download, it sounds as though it will work offline, with no internet access.

And if people use it for that reason, then they are going to be disappointed when it doesn't work.

So I was just clarifying that your (cleaner, easier) way of accessing images from a URL, still does a download, and therefore still needs internet access to work.
 

jkhazraji

Active Member
Licensed User
Longtime User
When you say it displays an image from a URL without download, it sounds as though it will work offline, with no internet access.

And if people use it for that reason, then they are going to be disappointed when it doesn't work.

So I was just clarifying that your (cleaner, easier) way of accessing images from a URL, still does a download, and therefore still needs internet access to work.
Thanks for your (clearer) words, I did not say it needs no internet access I just meant no file is downloaded in the process.
 
Top