Autor Beitrag
Andi1982
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Di 15.06.04 08:38 
Hallo,
ich habe hier im forum zwar schon www.delphi-forum.de/...hlight=jpg+speichern gefunden, aber ich weiß nicht wie ich das in die Screenshot-funktion einbauen muss. Diese funktion habe ich aus den FAQ hier, aber wie gesagt speichert es die screenshots als BMP's.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
function FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
var
  Rec: TRect;
  iWidth, iHeight: Integer;
begin
  with TBitmap.Create do try
    GetWindowRect(h, Rec);


    iWidth  := Rec.Right - Rec.Left;
    iHeight := Rec.Bottom - Rec.Top;


    Width := iWidth;
    Height := iHeight;
    BitBlt(Canvas.Handle, 0, 0, iWidth, iHeight, GetWindowDC(h), 0, 0, SRCCOPY);
    Result := True;


    try SaveToFile(Filename) except Result := False end;
  finally
    ReleaseDC(h, GetWindowDC(h));
    Free;
  end;
end;


Aus dem anderen Thread habe ich diesen code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
jpgfile := TJPEGImage.Create;  
  try  
    jpgfile.Assign(bitmapvar);  
    jpgfile.SaveToFile('C:\test.jpg');  
  finally  
    jpgfile.Free;  
  end;


nur wie muss ich den einbauen? Mein problem ist dass ich nicht weiß was ich anstelle von Bitmapvar da reinmachen muss in meinem fall.

Kann mir jemand helfen :( ?

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
umpani
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 389



BeitragVerfasst: Di 15.06.04 09:23 
Versuch es mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
function FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
var
  Rec: TRect;
  iWidth, iHeight: Integer;
  screenimage:tbitmap;
  jpgfile:tjpegimage;
begin
  screenimage := tbitmap.Create;
  with screenimage do try
    GetWindowRect(h, Rec);
    iWidth  := Rec.Right - Rec.Left;
    iHeight := Rec.Bottom - Rec.Top;
    Width := iWidth;
    Height := iHeight;
    BitBlt(Canvas.Handle, 0, 0, iWidth, iHeight, GetWindowDC(h), 0, 0, SRCCOPY);
    Result := True;
  finally
    jpgfile := TJPEGImage.Create;  
      try
        jpgfile.Assign(screenimage);
        jpgfile.SaveToFile(Filename);
      finally
        jpgfile.Free;
      end;
    ReleaseDC(h, GetWindowDC(h));
    Free;
  end;
end;



Gruß Umpani

_________________
Lernen, ohne zu denken, ist eitel; denken, ohne zu lernen, ist gefährlich. Konfuzius
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Di 15.06.04 09:54 
Danke Umpani! Das funktioniert super!!!

Allerdings habe ich das mit der jpgfile vor das Finally gesetzt, so wars ja vorher auch.

Also vielen dank nochmal!

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...