I am using the TEdgeBrowser
component in a browser/viewer Delphi application. I had few issues after a brief learning curve for the original implementation.
I am now at a point where I can experiment with some of the features (like screen capture).
To capture a screen to a file, you can simply add:
EdgeBrowser1.CapturePreview(ScrFileName);
Where ScrFileName
is the path of the file i.e. c:\pic\screenshot.png
I would like to capture the screen every second (and relay it using an Indy component (TIdHTTPServer
) to relay it internally (http).
I am able to do this as follows, but it's very inefficient. Can anyone recommend an alternative?
procedure TMainForm.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
Const
EOL = #13;
var
Strm: TMemoryStream;
begin
if ARequestInfo.Document = '' then
begin
AResponseInfo.Redirect('/');
end
else if ARequestInfo.Document = '/' then
begin
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'text/html';
AResponseInfo.ContentText := '<!DOCTYPE html>'+EOL+
'<html>'+EOL+
'<head>'+EOL+
'<meta name="viewport" content="width=device-width, initial-scale=5">'+EOL+
'<meta http-equiv="Refresh" content=1>'+EOL+
'<style type="text/css">'+EOL+
' img.fullscr {'+EOL+
' display:block;'+EOL+
' width:100%;'+EOL+
' }'+EOL+
'</style>'+EOL+
'</head>'+EOL+
'<body>'+EOL+
'<img src="/image" class="fullscr">'+EOL+
'</body>'+EOL+
'</html>'+EOL;
end
else if ARequestInfo.Document = '/image' then
begin
Strm := TMemoryStream.Create;
try
Strm.Clear;
Strm.LoadFromFile(ScrFileName);
Strm.Position := 0;
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'image/png';
AResponseInfo.ContentStream := Strm;
except
Strm.Free;
raise;
end;
end
else begin
AResponseInfo.ResponseNo := 404;
end;
end;