this slowpoke moves

Create Screenshot & Save Bitmap

function GetScreenShot: TBitmap;
var
  Desktop: HDC;
begin
  Result  := TBitmap.Create;
  Desktop := GetDC(0);
  try
    try
      Result.PixelFormat := pf32bit;
      Result.Width := Screen.Width;
      Result.Height := Screen.Height;

      BitBlt(Result.Canvas.Handle, 0, 0,
             Result.Width,
             Result.Height,
             Desktop,
             0,
             0,
             SRCCOPY);

      Result.Modified := True;
    finally
      ReleaseDC(0, Desktop);
    end;
  except
    Result.Free;
    Result := nil;
  end;
end;
Screenshot erstellen :
procedure TForm1.Button1Click(Sender: TObject);
begin
 Image1.Picture.Bitmap := GetScreenShot;
end;
Screenshot als Bitmap Speichern :
procedure TForm1.Button2Click(Sender: TObject);
var DCDesk: HDC;
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  bmp.Height := Screen.Height;
  bmp.Width := Screen.Width;
  try
      DCDesk := GetWindowDC(GetDesktopWindow);
      BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,
         DCDesk, 0, 0, SRCCOPY);
      bmp.SaveToFile('ScreenShot.bmp');
      ReleaseDC(GetDesktopWindow, DCDesk);
    finally
  bmp.Free;
  end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate