PDA

Просмотр полной версии : Делаем скриншот средствами Delphi


DroN.ExE
04.10.2013, 01:10
----------------------------------------------------------------------------------------------------------------------------------

Снимок экрана

----------------------------------------------------------------------------------------------------------------------------------
var
Canvas:TCanvas;
ScreenV:HDC;
begin
ScreenV := GetDC(0);
Canvas:=TCanvas.Create();
Canvas.Handle:=ScreenV;
Image1.Canvas.Copyrect(Rect(0,0,Image1.Width,Image 1.Height),
Canvas, Rect(0,0,Screen.Width,Screen.Height));
ReleaseDC(0,ScreenV);
Canvas.Free;
Image1.Picture.SaveToFile('1.jpg');

----------------------------------------------------------------------------------------------------------------------------------

procedure GetWindowsScreen( PathToSave: string );
begin
with TBitmap.Create do
begin
Width := Screen.Width;
Height := Screen.Height;
BitBlt( Canvas.Handle, 0, 0, Width, Height, GetDC( GetDesktopWindow ), 0, 0, SRCCOPY );
if not DrawIcon(Canvas.Handle,Mouse.CursorPos.X,Mouse.Cur sorPos.Y,GetCursor) then
begin
end;
SaveToFile( PathToSave );
Free;
end;
end;


----------------------------------------------------------------------------------------------------------------------------------
uses: jpeg


function ScreenSCR(): TBitmap;
var
ScreenDC: HDC;
begin
Result := TBitmap.Create;
with Result do
begin
Width := Screen.width;
Height := Screen.height;
ScreenDC := GetDC( 0 );
try
BitBlt( Canvas.Handle, 0, 0, Width, Height, ScreenDC,
0, 0, SRCCOPY );
finally
ReleaseDC( 0, ScreenDC );
end;
end;
end;

function SCR(input:TBitmap):TJPEGImage;
begin
Result:=TJPEGImage.Create;
Result.Assign(input);
Result.CompressionQuality:=50;
Result.ProgressiveEncoding:=true;
Result.Compress;
end;


SCR(ScreenSCR).SaveToFile('1.jpg');
----------------------------------------------------------------------------------------------------------------------------------

DesktopCanvas:=TCanvas.Create;
DesktopCanvas.Handle:=GetDC(Hwnd_Desktop);
BitMap := TBitMap.Create;
BitMap.Width := Screen.Width;
BitMap.Height:=Screen.Height;
Bitmap.Canvas.CopyRect(Bitmap.Canvas.ClipRect,
DesktopCanvas, DesktopCanvas.ClipRect);
bitmap.SaveToFile(‘c:\windows\screen.bmp’);