HanDs
管理员

[Delphi文章] 截屏存盘 



procedure TForm1.ScreenCap(LeftPos,TopPos,RightPos,BottomPos:integer);
var
  RectWidth,RectHeight:integer;
  SourceDC,DestDC,Bhandle:integer;
  Bitmap:TBitmap;
  MyJpeg: TJpegImage;
  Stream:TMemoryStream;
begin
  MyJpeg:= TJpegImage.Create;
  RectWidth:=RightPos-LeftPos;
  RectHeight:=BottomPos-TopPos;
  SourceDC:=CreateDC('DISPLAY','','',nil);
  DestDC:=CreateCompatibleDC(SourceDC);
  Bhandle:=CreateCompatibleBitmap(SourceDC,
  RectWidth,RectHeight);
  SelectObject(DestDC,Bhandle);
  BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,
  LeftPos,TopPos,SRCCOPY);
  Bitmap:=TBitmap.Create;
  Bitmap.Handle:=BHandle;
  Stream := TMemoryStream.Create;
  Bitmap.SaveToStream(Stream);
  Stream.Free;
  try
    MyJpeg.Assign(Bitmap);
    MyJpeg.CompressionQuality:=70;
    MyJpeg.Compress;
    MyJpeg.SaveToFile('C:MyJPEGImage.JPG');
  finally
    MyJpeg.Free;
    Bitmap.Free;
    DeleteDC(DestDC);
    ReleaseDC(Bhandle,SourceDC);
  end;
end;

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xujh/archive/2007/04/28/1589525.aspx


学习中请遵守法律法规,本网站内容均来自于互联网,本网站不负担法律责任
存盘
#1楼
发帖时间:2016-7-9   |   查看数:0   |   回复数:0
游客组
快速回复