Hola Gerson12.
En Form1, tál como en tu pantalla, pone dos
TEdit con sus respectivos
Tlabel y un
TButton :
Código Delphi
[-]
...
implementation
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2:= TForm2.Create(Self);
Form2.UrlToImage(Edit1.Text, Form2.Image1);
Form2.Label1.Caption:= Edit2.Text;
Form2.ShowModal;
end;
end.
En Form2 pone un
TLabel (Aling: alBottom, Alignment: taCenter), un
TImage (Align: alClient) y un
TIdHTTP (pestaña Indy Clients):
Código Delphi
[-]
...
type
TForm2 = class(TForm)
...
public
procedure UrlToImage(const URL:string; aImage:TImage);
end;
...
implementation
uses jpeg;
procedure TForm2.UrlToImage(const URL:string; aImage:TImage);
var
s: string;
MStream: TMemoryStream;
JPGImg: TJPEGImage;
begin
try
s:= idHTTP1.Get(URL);
except
raise Exception.Create('Error: No se encontró la imágen');
end;
MStream:= TMemoryStream.Create;
JPGImg:= TJPEGImage.Create;
try
MStream.Write(s[1], Length(s));
MStream.Position:= 0;
JPGImg.LoadFromStream(MStream);
aImage.Picture.Assign(JPGImg);
finally
MStream.Free;
JPGImg.Free;
end;
end;
end.
Quitá a Form2 de Auto-create forms.
Saludos.