Android Question Tiles_JE - Custom picture path

stp

Active Member
Licensed User
Longtime User
Is it possible to use pictures direct from web ?
i use now:
B4X: Copy
Dim img As ImageView = Tiles_JE1.AddImageResize("Im2", "b4j.png", xui.Color_DarkGray, 70dip, 70dip)
would like to use eg:
B4X: Copy
Dim img As ImageView = Tiles_JE1.AddImageResize("Im2", "https://www.mysite.com/my.png", xui.Color_DarkGray, 70dip, 70dip)
but as long i use last line my app crashes
 
you need to download the image first! Check this thread!
 
Upvote 0
you need to download the image first! Check this thread!
Did you worked with Tiles_JE? Dont think that works.. Is there any small example ?
 
Upvote 0
If you unzip the Tiles_JE library you will find out the
B4X: Copy
Public Sub AddImage (pTag As String, pBitmap As String, pBackgroundColor As Int) As ImageView
sub uses
B4X: Copy
img.Bitmap = LoadBitmap(File.DirAssets, pBitmap)
So Tiles_je can not support for now Url links.. need to be modified ;)
 
Upvote 0
Not directly, but you CAN use online images by downloading them into a bitmap object and use that as sourche
 
Upvote 0
Not directly, but you CAN use online images by downloading them into a bitmap object and use that as sourche
ok is there any example ? Can i apply that also in my case. ? Does it work also with tiles_je?
 
Upvote 0
Found a solution using:
B4X: Copy
Sub Globals
    Private ImageView1 As ImageView
    Private btnLoadImage As Button
End Sub

Sub btnLoadImage_Click
    Dim MyLink As String
    MyLink="https://www.b4x.com/images3/android.png"
    DownloadImage(MyLink, ImageView1)
End Sub

'Good example. Use:
Sub DownloadImage(Link As String, iv As ImageView)
    Dim job As HttpJob
    job.Initialize("", Me) 'note that the name parameter is no longer needed.
    job.Download(Link)
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        iv.Bitmap = job.GetBitmap
    End If
    job.Release
End Sub

Same way i will use also database saved pictures (the links)
 
Upvote 0
The Tiles_JE library is intended as a "selection". Eg. as a replacement for B4XComboBox. That is, I choose from a menu that is represented by tiles. It is not intended as an image viewer.
It is not about imageviewer. Want to assign a custom small picture in the tiles. As you see it is not possible to include all icons or pictures in the app.
Pictures are saved in files on web or databases that point to an url or even base64 pictures that are hosted in db. There is a need to be flexible. So i checked your library and found it out myself.. Thank you for your reply. I fixed my code with some workaround.
 
Last edited:
Upvote 0
But it is possible to add also an image from url as also from db (link) or base64 image here how i did:
B4X: Copy
    Public ppp As String = "b4j.png"
    
    Dim img As ImageView = Tiles_JE1.AddImage("Im1", ppp, xui.Color_DarkGray)   
    Dim MyLink As String
    MyLink="https://freepngimg.com/thumb/free/3-2-free-png-picture.png"
    DownloadImage(MyLink, img)
    
    Dim img As ImageView = Tiles_JE1.AddImage("Im2", ppp, xui.Color_DarkGray)
    Public bspic As String ="iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAP9JREFUeNrs3LEJg0AUgOEYnMMZHCFWmccqM6RyBTNGqjiCIwQnyAan5ZFCECL4yPfDgQdXiB++wsIipXTScTp7BEAEBIiAABEQIAICREAEBIiAABEQIAICREAEBIiAABEQIAICREAEBIiAABEQIAICREAEBIiAANGPKqPdcHW9vzYcf0zPWw9k3y4bzg5Glv7uDWmy63pZXbYfl9Vm+zeQ/VsbQ5+IY8rIAiIgQAQEiIAAERABOWpl8Pv//lQyRgcp/GrcyBIQIAICRECACAgQAREQIAICRECACAgQAREQIAICRECACAgQAREQIAICRECACAgQAREQIAISt1mAAQB0ixTczXFPFAAAAABJRU5ErkJggg=="
    img.Bitmap = Base64EncodeDecodeImage.Base64StringToImage(bspic)

the download image code is in previous post.
 
Upvote 0
You can use this directly to load images from URLs; it's more secure. If you want, you can adapt it so you send the URL and it returns the image. This is what I did for a solution.


Note
It's also included in SMM.
 
Upvote 0
Back
Top