Android Question How do i implement fill imageview to imagedownloader?

Reminisce

Active Member
I needed to use the "FILLIMAGEVIEW" and the Roundimage in my imagedownloader, so i used two different imagedownloader services instead, i dont want to use this technique is there a way i can incorporate the 2?
using

FILLIMAGEVIEW:
Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)
    Dim bmpRatio As Float = bmp.Width / bmp.Height
    Dim viewRatio As Float = ImageView.Width / ImageView.Height
    If viewRatio > bmpRatio Then
        Dim NewHeight As Int = bmp.Width / viewRatio
        bmp = bmp.Crop(0, bmp.Height / 2 - NewHeight / 2, bmp.Width, NewHeight)
    Else if viewRatio < bmpRatio Then
        Dim NewWidth As Int = bmp.Height * viewRatio
        bmp = bmp.Crop(bmp.Width / 2 - NewWidth / 2, 0, NewWidth, bmp.Height)
    End If
    ImageView.SetBitmap(bmp.Resize(ImageView.Width, ImageView.Height, True))
    
End Sub

AND

CODE TO SET ROUND BITMAP:
            nativeme.InitializeContext
            Dim bm As Bitmap
            bm.Initialize3(bmp)
            Dim bordercolor,borderwidth As Int
            bordercolor = Starter.colourpurple
            borderwidth = 0
    
            Dim bm1 As Bitmap = nativeme.RunMethod("getRoundBitmap",Array(bm,bordercolor, borderwidth))

Doesnt work, one works and the other doesnt, how do i use both?

DOE
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Reminisce

Active Member
Thank you erel! I will check it out.

You are amazing, I got what i needed.

B4X:
Sub DownloadImage(Link As String, iv As ImageView)

   Dim j As HttpJob

   j.Initialize("", Me)

   j.Download(Link)

   Wait For (j) JobDone(j As HttpJob)

   If j.Success Then

     iv.Bitmap = j.GetBitmap

   End If

   j.Release

End Sub

For learning sake, does the above code mean we can download and show an image directly inside an imageview without the hassle of using "Outputstream"?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…