Autor Beitrag
mick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Mo 03.01.05 17:07 
hi.

moechte einen screenshot der hauptform als jpg-datei auf platte speichern. wie geht das? diese ausdrucken ist leicht:

ausblenden Delphi-Quelltext
1:
UHauptForm.Print;					


aber speichern als bild?

ciao,
mijozi.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 03.01.05 17:21 
Es als Bitmap zu speichern ist auch ganz einfach:

ausblenden Delphi-Quelltext
1:
Form1.GetFormImage.SaveToFile('bild.bmp');					


Jetzt musst du es nur noch konvertieren ins JPEG-Format. :-)

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 03.01.05 17:53 
Zitat:
Jetzt musst du es nur noch konvertieren ins JPEG-Format.

Das machst du so:

ausblenden Delphi-Quelltext
1:
2:
3:
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, JPEG;

Das "JPEG" musst du oben bei uses dazuschreiben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  Form1: TForm1;
  jpgimage: TJPEGImage;
  bmpimage: TImage;

Das fehlt bei "var".

In deiner Prozedur schreibst du:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Form1.GetFormImage.SaveToFile('C:\bild.bmp');
bmpimage := TImage.Create(Form1);
bmpimage.Picture.LoadFromFile('C:\bild.bmp');
jpgimage := TJPEGImage.Create();
jpgimage.Assign(bmpimage.Picture.Bitmap);
jpgimage.SaveToFile('C:\bild.jpg');
DeleteFile('C:\bild.bmp');
jpgimage.Free;
bmpimage.Free;


Hoffentlich funktioniert's... :-)

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
sibbe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

WIN XP Prof
D7 Prof
BeitragVerfasst: Mo 03.01.05 18:03 
Warum nicht einfach wenns auch komplizierter geht? :wink:
das ganze geht auch weniger code- und ressourcenlastig:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
uses [..] jpeg;

...

procedure DeineProc;
var jpg: TJPEGImage;
begin
  jpg := TJPEGImage.Create;
  jpg.Assign(Form1.GetFormImage);
  jpg.SaveToFile('C:\Bild.jpg');
  jpg.Free;
end;


greetz sibbe

_________________
Ideale sind wie Sterne: Man kann sie zwar nicht erreichen, aber man kann sich sehr wohl an ihnen orientieren.
(Blaise Pascal)
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 03.01.05 18:07 
Ja stimmt, sorry, hab' das mit dem Assign auch erst rausfinden müssen.

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
sibbe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

WIN XP Prof
D7 Prof
BeitragVerfasst: Mo 03.01.05 18:11 
warum sorry? vor noch nicht all zu langer zeit hätte ich selbst da mit WinApi und Screenhooks draufgeschossen :)
Außerdem funktioniert der code ja, so oder so ;)

_________________
Ideale sind wie Sterne: Man kann sie zwar nicht erreichen, aber man kann sich sehr wohl an ihnen orientieren.
(Blaise Pascal)
mick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 159



BeitragVerfasst: Mo 03.01.05 18:36 
super, leute - danke!

ciao,
mijozi.