How it works...

Open the project at Chapter03\RECIPE03\NetEncoding.dproj and launch it. In the edit section on the left, write 500 (or another valid ID in your database). Now, the form should look like the following:

Figure 3.4: The image has been downloaded as base64 text from a REST service and then decoded and loaded in the TImage control

Stop the program and see the code under the Get Photo button:

procedure TMainForm.btnGetPhotoClick(Sender: TObject); 
var 
  LHTTP: THTTPClient; 
  LResponse: IHTTPResponse; 
  LPNGStream: TMemoryStream; 
  LPNGImage: TPngImage; 
  LURLFormat: string; 
begin 
  LHTTP := THTTPClient.Create; 
  try //create the correct URL LURLFormat ...

Get Delphi Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.