I'm using Embarcadero RAD Studio 2010 Delphi.
I was testing to capture screen images from other computers via sockets. So I came across an error in capturing the screen and turning to JPG (or even recording as default BMP), after about 10 seconds - running a TTimer
with a range of 400 gives the error:
[projectname] raised exception class EOutOfResources with message 'Insufficient storage space to process this command.'.
When you see the Timer event code, you will see that (for tests) I'm just running function CapturaTelaJpg
without saving it at all (but it saves perfectly), and even then the error occurs after 10 seconds. / p>
function CapturaTelaJpg: TJpegImage;
var
dc : hdc;
cv : TCanvas;
aux : TBitmap;
begin
Result := TJPEGImage.Create;
aux := TBitmap.Create;
aux.Height := Screen.Height;
aux.Width := Screen.Width;
dc := GetDC(0);
cv := TCanvas.Create;
cv.Handle := dc;
//--Define o tamanho da imagem
aux.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),cv,
Rect(0,0,Screen.Width,Screen.Height));
cv.Free;
cv := nil;
ReleaseDC(0,dc);
//-- Compacta o BMP para JPEG
Result.Assign(aux);
aux.Free;
aux := nil;
Result.Compress;
end;
Timer1
with interval 400
procedure TfrmMonitorando.Timer1Timer(Sender: TObject);
begin
CapturaTelaJpg; // 10s depois, ocorre o erro colocando ou não numa variável
end;