Hi!
I was interested about the speed of an endless loop taking a screenshot and assign it to an image.
That's what I did:
var loopRunning : Boolean = false;
procedure TForm1.Test1Click(Sender: TObject);
var
bmp: TBitmap;
DC: HDC;
Starttime: QWord;
begin
LoopRunning := NOT LoopRunning;
if loopRunning then
begin
repeat
Starttime := GetTickCount64;
bmp := TBitmap.Create;
DC := GetDC(0);
try
bmp.LoadFromDevice(DC);
application.ProcessMessages;
finally
ReleaseDC(0, DC);
end;
bmp.Canvas.TextOut(10,10,IntToStr(GetTickCount64-Starttime)+' ms');
image1.Picture.Bitmap.Assign(bmp);
FreeAndNil(bmp);
application.ProcessMessages;
until NOT loopRunning;
end;
end;
Important is the application.ProcessMessages in the loop so that you can access the machine.
Without any other user actions the needed time per loop is 13-15 ms on my hardware.
Top says it needs 67% CPU time out of 800%.
I Think much higher speed you will not reach with Lazarus.
Except better hardware.
Or except creating low level routines.
Winni