close

//uses jpeg

procedure TForm1.Button1Click(Sender: TObject);
var
  DC: HDC;
  Canvas: TCanvas;
  MyBitmap: TBitmap;
  jpg: TJpegimage;
begin
  Canvas := TCanvas.Create;
  MyBitmap := TBitmap.Create;
  DC := GetDC(0);
  jpg := TJpegImage.Create;
  try
    Canvas.Handle := DC;
    with Screen do
    begin
      MyBitmap.Width := Width;
      MyBitmap.Height := Height;

      MyBitmap.Canvas.CopyRect(
        Rect(0, 0, Width, Height), Canvas,
        Rect(0, 0, Width, Height));
      jpg.Assign(MyBitmap);
      jpg.SaveToFile('1.jpg');
    end;

  finally
    { free memory }
    ReleaseDC(0, DC);
    MyBitmap.Free;
    Canvas.Free;
    jpg.Free;
  end;
end;

arrow
arrow
    文章標籤
    截圖 Delphi DC GetDC
    全站熱搜

    抓狂小白 發表在 痞客邦 留言(0) 人氣()