BitmapDataPath Example for Delphi

This example shows how to load an image from the Internet. It uses the BitmapDataPath property to start the asynchronous load; then uses the ReadyStateChange event to paint the image when loading is complete.

//declare the RasterIO object.
var
RasterIO: LEADRasterIO;

procedure TForm1.Button1Click(Sender: TObject);
begin
       RasterIO:= CreateComObject(CLASS_LEADRasterIO) as LEADRasterIO;
   LEADEventSink1.Connect (RasterIO, _LEADRasterIOEvents);
   //Start the asynchronous load.
   RasterIO.BitmapDataPath (LEADRasterView1.Raster, WideString('http://www.leadtools.com/images/tiger2.cmp'));
end; 

procedure TForm1. LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
  const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
  varResult, ExcepInfo, ArgErr: Pointer);
var
   sRet: Smallint;
   ReadyState: Integer;
begin
   case (DispID) of
      LEADRASTERIOEVENTS_READYSTATECHANGE:
      begin
         ReadyState:= OleVariant(Params.rgvarg^[0]);
          //Paint the image when loading is complete.
          if (ReadyState = RASTER_READYSTATE_COMPLETE) then
         begin
            LEADRasterView1.AutoSetRects:= True;
              LEADRasterView1.PaintSizeMode:= PAINTSIZEMODE_FIT;
              LEADRasterView1.ForceRepaint (sRet);
          end;
      end;
   end;
end;