title: delphi download image without refresh the page
body: <p>There is a webpage which includes an basic Captcha image, i solved captcha downloading image from website and using Tesaract. I'm using this function to show image in a Timage object without download;</p>
  
  <pre><code>FUNCTION DownloadImage(CONST URL : STRING ; ImageType : TGraphicClass = NIL) : TBitMap;
    VAR
      HTTP        : TIdHttp;
      S           : TStream;
      IMG         : TGraphic;
      STR         : AnsiString;
      LHandler: TIdSSLIOHandlerSocketOpenSSL;
  
    BEGIN
      HTTP:=TIdHttp.Create(NIL);
      LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
      TRY
        HTTP.IOHandler:=LHandler;
        S:=TMemoryStream.Create;
        TRY
          HTTP.Get(URL,S);
          IF NOT Assigned(ImageType) THEN BEGIN
            S.Position:=0;
            SetLength(STR,5);
            S.Read(STR[1],LENGTH(STR));
            IF COPY(STR,1,2)='BM' THEN
              ImageType:=TBitMap
            ELSE IF COPY(STR,1,3)='GIF' THEN
              ImageType:=TGIFImage
            ELSE IF COPY(STR,2,3)='PNG' THEN
              ImageType:=TPngImage
            ELSE IF (ORD(STR[1])=$FF) AND (ORD(STR[2])=$D8) THEN
              ImageType:=TJPEGImage
          END;
          IF NOT Assigned(ImageType) THEN RAISE EInvalidImage.Create('Unrecognized file format!');
          IMG:=ImageType.Create;
          TRY
            S.Position:=0;
            IMG.LoadFromStream(S);
            Result:=TBitMap.Create;
            TRY
              Result.Assign(IMG)
            EXCEPT
              Result.Free;
              RAISE
            END
          FINALLY
            IMG.Free
          END
        FINALLY
          S.Free
        END
      FINALLY
        HTTP.Free
      END
    END;
  </code></pre>
  
  <p>or for download image</p>
  
  <pre><code>function DownLoadInternetFile(Source, Dest : String): Boolean;
  begin
    try
      Result := URLDownloadToFile(nil,PChar(Source),PChar(Dest),0,nil) = 0
    except
      Result := False;
    end;
  end;
  </code></pre>
  
  <p>the problem is both of those functions connecting to web site to get image and because of this when i navigate the page with webbrowser on my form downloaded captcha picture and browsed page's captcha picture are different, the thing i i'm trying to do is get the picture from embeddedwb or webbrowser object directly when document complete, i also tryed to get screenshot of the webbrowser at runtime but i failed, the web page is :"https://esgm.sgk.gov.tr/Esgm/", thanks in advance.Sorry for bad English</p>