I have a TImage component in a XE7 FMX Android form. I would like to load images from the web onto it. I found this article, but unfortunately it seems to work only in Delphi XE5. I could use the Indy components to perform such task, but I would like to exhaust all possibilities before the inclusion of Indy in the project. Google isn't helping in this case, does anyone faced a similar situation? Is there a way to load images from a http site to a TImage component, without the use of Indy?
-
What's wrong with using a library to download files? If you don't want to use a library, are you prepared to write the code necessary to download files? And if so, what is preventing you from doing that? – David Heffernan Jun 24 '15 at 15:06
-
@David No, I'm not prepared to write a library to do it, I'm very new to FireMonkey and Android, that's why I came here to see if someone could help me. The reason to try to do it without Indy is pure formality, sounds silly but I need to justify the inclusion of new libraries in the project I'm working on, I avoid bureaucracy if I can hard code a solution in Pascal lines directly in the my code. – André Murta Jun 24 '15 at 15:25
-
Indy is the library that Embarcadero supply for this purpose. If you don't want to use Indy, find a different library, or write your own code. – David Heffernan Jun 24 '15 at 15:26
-
@David I do not understand this bitterness David, The question I asked is clear, there is no information in Google about it, except for the small class that works in XE5 but not in XE7, what makes me believe that someone more experienced in FMX could know how to port it (and it seems that's the case). If you don't know or don't want to help, just don't do it, I'm not asking for your help directly neither forcing you to answer the question. – André Murta Jun 24 '15 at 15:33
-
There's no bitterness at all. I just stated a plain opinion. Use Indy. Don't use Indy. Up to you. If you don't want to use Indy, you'll need to find an alternative. The class you refer to does indeed perform HTTP downloading. And it does so by using Indy. Which makes the question very hard to fathom. Did you not look at the code of this class? Had you done so you would surely have seen the reference to Indy. Again, as I said, you can do one of the following: 1. Use Indy. 2. Use a different library. 3. Write your own code. – David Heffernan Jun 24 '15 at 15:40
-
@David It looks like bitterness. If you you are making reference to the line: IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, To link the code to Indy, I can assure you you can remove it (I did) and it will compile same way, that makes me believe it is just old code not removed by the programmer. Unfortunately still no working in XE7. I see no reference to Indy in the unit AsyncTask. – André Murta Jun 24 '15 at 16:00
-
Please read the code. It's here: https://github.com/dkstar88/AsyncTask/blob/master/AsyncTask.HTTP.pas It clearly uses Indy to do the download. – David Heffernan Jun 24 '15 at 16:05
-
@David Do you have access to the XE7? The code you posted includes IdHttp in the uses clause. Is that the reference to Indy you mentioned? I ask if you have access to XE7, because things are not so clear in the file "AsyncTask.pas" I have here with me. It is far differente this one you posted. – André Murta Jun 24 '15 at 16:17
-
The HTTP code is in `AsyncTask.HTTP.pas`. `AsyncTask.pas` doesn't do any HTTP. As I said, the code you refer to is based on Indy. XE7 doesn't come in to this really. I've not compiled anything. All I did was read the code. There's not very much of it. – David Heffernan Jun 24 '15 at 16:20
-
@David unit AsyncTask; interface uses SysUtils, Classes, Rtti, Types, FMX.Types, System.Generics.Collections; type IAsyncTask = interface; TTaskStatus = (tsNone, tsRunning, tsComplete); TTaskEvent = reference to procedure (ATask: IAsyncTask); TNamedParams = TDictionary
; IAsyncTask = interface ['{4CF30AFF-C915-48DB-9878-8995E052700B}'] procedure SetData(const Value: TValue); procedure SetOnFinish(const Value: TTaskEvent); procedure SetOnStart(const Value: TTaskEvent); ... – André Murta Jun 24 '15 at 16:20 -
Yes, I can see that code. But it doesn't do any HTTP download. – David Heffernan Jun 24 '15 at 16:25
-
So, have you got to the bottom of this yet? – David Heffernan Jun 25 '15 at 12:43
1 Answers
The code that you refer to in the question can readily be ported to XE7, if indeed it does not compile in XE7, a fact that I did not confirm.
However, that code uses Indy to perform the HTTP download. It does so in the AsyncTask.HTTP
unit. So your analysis that this code is an Indy free, library free, way to download HTTP content is quite simply incorrect. The premise of your question is false.
Is there a way to load images from a http site to a TImage component, without the use of Indy?
Sure there is. You can:
- Find a different networking library that can perform HTTP downloads.
- Write your own code to perform HTTP downloads.
The latter option is certainly feasible. After all, that's all that Indy does. No doubt it wraps up the platform networking libraries. So you could write your own code that stands on top of the platform networking libraries, but I don't really see much point in doing that. Not least because it is a non-trivial task.

- 601,492
- 42
- 1,072
- 1,490