delphi实现屏幕抓图


procedure TForm1.Button1Click(Sender: TObject);
var
Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
dc:HDC;
myJpeg:TJpegImage;
begin
Fullscreen := TBitmap.Create; // create a bimap to save picture
myJpeg := TJpegImage.Create;
Fullscreen.Width := screen.width;
Fullscreen.Height := screen.Height;
DC := GetDC (0); // get screen dc
FullscreenCanvas := TCanvas.Create; //create screen canvas
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect (Rect (0, 0, screen.Width, screen.Height), fullscreenCanvas,Rect (0, 0, Screen.Width, Screen.Height));
FullscreenCanvas.Free; //free screencanvas
ReleaseDC (0, DC);
//*******************************image1.picture.Bitmap:=fullscreen;//哈哈,拿到屏幕了!
image1.Width:=fullscreen.Width;
image1.Height:=fullscreen.Height;
image1.Picture.bitmap:=fullscreen;
myJpeg.Assign(Image1.Picture.Bitmap);
myJpeg.CompressionQuality := 50;
myJpeg.Compress;
myJpeg.SaveToFile('1.jpg');
myJpeg.Free;

end;


联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678