Hey,
ich habe eine Funktion, mit der ich einen Screenshot des kompletten Desktops erstellen kann:
Delphi-Quellcode:
procedure TScreenCaptureThread.CreateBitmapScreenShot(Bitmap: TBitmap;
Format: TPixelFormat; Ratio: TResolutionRatio);
var
C: TCanvas;
R: TRect;
Width, Height: Integer;
B: TBitmap;
begin
C := TCanvas.Create;
C.Handle := GetWindowDC(GetDesktopWindow);
try
Width := GetSystemMetrics(SM_CXSCREEN);
Height := GetSystemMetrics(SM_CYSCREEN);
R := Rect(0, 0, Width, Height);
if (Ratio = 100) then
begin
Bitmap.Width := Width;
Bitmap.Height := Height;
Bitmap.PixelFormat := Format;
Bitmap.Canvas.CopyRect(R, C, R);
end else
begin
B := TBitmap.Create;
try
B.Width := Width;
B.Height := Height;
B.PixelFormat := Format;
B.Canvas.CopyRect(R, C, R);
Bitmap.Width := Round(Width * 0.01 * Ratio);
Bitmap.Height := Round(Height * 0.01 * Ratio);
Bitmap.PixelFormat := Format;
Bitmap.Canvas.StretchDraw(Rect(0, 0, Bitmap.Width, Bitmap.Height), B);
finally
B.Free;
end;
end;
finally
ReleaseDC(0, C.Handle);
C.Free;
end;
end;
Jetzt will ich allerdings gerne auf die Graphics.pas
Unit verzichten und kann daher auch nicht mehr die Klassen TCanvas und TBitmap verwenden. Meine Frage jezt:

Welche Windows APIs benötige ich, um die Screenshot Funktion ohne die Delphi
RTL nachzubilden?

Und ganz wichtig: Wie kann ich das so erstellte Bitmap dann in einer Datei oder einem Buffer speichern?
Viele Grüße
Zacherl