Skip to content

Commit

Permalink
Added CaptureRect procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 15, 2009
1 parent 3430e27 commit fdd8e0d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Delphi/utils/SCapture.pas
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function MonitorCount : Integer;
// This captures Screen with the given TCaptureContext into the destBitmap
procedure CaptureScreen(aCaptureContext : TCaptureContext; destBitmap : TBitmap;aMonitorNum : Integer = 1);

procedure CaptureRect(aCaptureRect : TRect;destBitMap : TBitmap); inline;

procedure CaptureDeviceContext(SrcDC: HDC;aCaptureRect : TRect;destBitMap : TBitmap); inline;

function GetMonInfoByIdx(MonIdx : Integer) : MONITORINFO;
Expand Down Expand Up @@ -167,6 +169,8 @@ procedure CaptureScreen(aCaptureContext : TCaptureContext; destBitmap : TBitmap;

procedure CaptureDeviceContext(SrcDC: HDC;aCaptureRect : TRect;destBitMap : TBitmap);
begin
// This is just in case you want to capture from a Device Context
// that is not the screen, or you already have the Device Context Handle
destBitmap.Width := aCaptureRect.Right - aCaptureRect.Left;
destBitmap.Height := aCaptureRect.Bottom - aCaptureRect.Top;
BitBlt(destBitmap.Canvas.Handle,
Expand All @@ -180,5 +184,18 @@ procedure CaptureDeviceContext(SrcDC: HDC;aCaptureRect : TRect;destBitMap : TBit
SRCCOPY) ;
end;

procedure CaptureRect(aCaptureRect : TRect;destBitMap : TBitmap); inline;
var
dc : HDC;
begin
dc := CreateDC('DISPLAY',nil,nil,nil);
try
CaptureDeviceContext(dc,aCaptureRect,destBitMap);
finally
ReleaseDC(0,dc);
end;
end;



end.

0 comments on commit fdd8e0d

Please sign in to comment.