ScreenCap

781 단어 delphi
procedure TForm1.ScreenCap(LeftPos, TopPos, RightPos, BottomPos: Integer);
var
  RectWidth, RectHeight: Integer;
  SourceDC, DestDC, Bhandle: Integer;
  Bitmap: TBitmap;
begin
  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;
  Image1.Picture.Bitmap := Bitmap;
  Bitmap.SaveToFile('test.bmp');
  Bitmap.Free;
  DeleteDC(DestDC);
  ReleaseDC(Bhandle, SourceDC);
end;

좋은 웹페이지 즐겨찾기