Registriert seit: 28. Aug 2002
Ort: Oldenburg
3.513 Beiträge
Turbo Delphi für .NET
|
Re: Screenshot in JPG ?!?
21. Okt 2003, 10:51
Mal eine (sehr) einfache Möglichkeit:
Delphi-Quellcode:
procedure ScreenToFile(aFileName: string);
var
Bitmap: TBitmap;
JPG : TJPEGImage;
Canvas: TCanvas;
begin
Canvas := TCanvas.Create;
try
Canvas.Handle := GetWindowDC(0);
try
Bitmap := TBitmap.Create;
JPG := TJPEGImage.Create;
try
Bitmap.Width := Screen.DesktopWidth;
Bitmap.Height:= Screen.DesktopHeight;
Bitmap.PixelFormat := pfDevice;
BitBlt(Bitmap.Canvas.Handle, 0, 0, Pred(Screen.DesktopWidth), Pred(
Screen.DesktopHeight), Canvas.Handle, Screen.DesktopLeft,
Screen.DesktopTop, Bitmap.Canvas.CopyMode);
JPG.Assign(Bitmap);
JPG.SaveToFile(aFileName);
finally
Bitmap.Free;
JPG.Free;
end;
finally
ReleaseDC(0, Canvas.Handle);
end;
finally
Canvas.Free;
end;
end;
(nicht getestet...)
Alexander
|
|
Zitat
|