Android Question Image downloader service and no extensions

bluedude

Well-Known Member
Licensed User
Hi,

I have some issues with the image downloader service when the URL has no file extension, any suggestions?
 

DonManfred

Expert
Licensed User
B4X:
Sub Activity_Resume
    Dim links As Map
    links.Initialize
    links.Put(ImageView1, "http://snapshots.basic4android.de/filewithoutext")
    links.Put(ImageView2, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.42.38.png")
    links.Put(ImageView3, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.52.19.png")
    links.Put(ImageView4, "http://www.basic4ppc.com/basic4android/images/SS-2012-02-06_12.45.56.png")
    CallSubDelayed2(ImageDownloader, "Download", links)
End Sub
The file http://snapshots.basic4android.de/filewithoutext IS an image... (it´s the upper one)
 

bluedude

Well-Known Member
Licensed User
Mmm, interesting. I do the same. The issue is that it does not seem to fetch the image.

Need to investigate it further.
 

DonManfred

Expert
Licensed User
try this URL
B4X:
Sub Activity_Resume
    Dim links As Map
    links.Initialize
    links.Put(ImageView1, "http://i1.adis.ws/i/wehkamp/248004_pb_01")
    links.Put(ImageView2, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.42.38.png")
    links.Put(ImageView3, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.52.19.png")
    links.Put(ImageView4, "http://www.basic4ppc.com/basic4android/images/SS-2012-02-06_12.45.56.png")
    CallSubDelayed2(ImageDownloader, "Download", links)
End Sub
 

bluedude

Well-Known Member
Licensed User
Hi Erel,
You mean I should replace this iv.SetBackgroundImage(bmp) with LoadBitMapSample? The Job only has a method to do getbitmap.

Or should I do a change in the GetBitMap itself?
 

bluedude

Well-Known Member
Licensed User
Hi,

I use the source code but the problem is that I want to keep aspect ratio because this is a real issue overall. How can I pre calculate the aspect ratio so I can set that with Width and Height before I download?
 

bluedude

Well-Known Member
Licensed User
Hi,

That seems to solve the large image problem, great. Now i'm wondering I i lose aspect ratio if I resize them slighty without taking aspect ratio into account.
 

Erel

Administrator
Staff member
Licensed User
Keeping the aspect ratio is quite complicated here. It will require finding the bitmap size without loading it (there are libraries that can do it) and then calculating the correct size. You can then load it with LoadBitmapSample. The last step will be to resize the image to the correct size as the bitmap loaded with LoadBitmapSample will usually be larger than the specified size.
 
Top