Autor Beitrag
Yooda
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 68



BeitragVerfasst: Do 15.01.04 21:05 
Hallöchen,

nach meinem gerade geschriebenem Post direkt ein zusätzlicher. Wenn ich einen Screenshot gemacht habe, möchte ich das Bild komprimiert speichern. Wie kann ich das machen? Ich habe die Bilder bisher im jpg-format gespeichert. Solch ein Bild wird bis zu 3 MB gross. Unverantwortlich diesen auf einen Webserver zu laden.

Viele Grüsse

David

Moderiert von user profile iconTino: Überflüssige Absätze entfernt.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Do 15.01.04 22:07 
3Mb für ein JPG bild o_O
das ist dann ja eigentlich schon komprimiert...
kann es sein, dass du es als BMP mit der DAteiendung JPG abgespeichert hast?
dadurch wird das ann nciht automatisch umgewandelt ...
alternativ kannst du die Bildgröße verkleinern...
Yooda Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 68



BeitragVerfasst: Do 15.01.04 22:10 
Du hast recht. Ich glaube ich habe es als BMP mit endung jpg gespeichert...

Wie mach ich es nur anders???
Hier mein Code:


ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdFTP,jpeg;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Timer1: TTimer;
    Edit1: TEdit;
    Timer2: TTimer;
    IdFTP1: TIdFTP;
    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

procedure ScreenShot(Bild: TBitMap); 
var 
  c: TCanvas; 
  r: TRect;
begin 
  c := TCanvas.Create; 
  c.Handle := GetWindowDC(GetDesktopWindow); 
  try 
    r := Rect(0, 0, Screen.Width, Screen.Height); 
    Bild.Width := Screen.Width; 
    Bild.Height := Screen.Height; 
    Bild.Canvas.CopyRect(r, c, r); 
  finally 
    ReleaseDC(0, c.Handle); 
    c.Free; 
  end; 
end;

{$R *.dfm}

procedure ScreenShotActiveWindow(Bild: TBitMap); 
var 
  c: TCanvas;
  r, t: TRect; 
  h: THandle; 
begin
  Bild.Monochrome:= true;
  c := TCanvas.Create;
  c.Handle := GetWindowDC(GetDesktopWindow);
  h := GetForeGroundWindow;
  if h <> 0 then
    GetWindowRect(h, t);
  try
    r := Rect(0, 0, t.Right - t.Left, t.Bottom - t.Top);
    Bild.Width  := t.Right - t.Left;
    Bild.Height := t.Bottom - t.Top;
    Bild.Canvas.CopyRect(r, c, t);
  finally
    ReleaseDC(0, c.Handle); 
    c.Free; 
  end; 
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
  Form1.Visible := False; 
  Sleep(750); //some delay,ein wenig Zeit geben
  Form2.Image1.Picture.Bitmap.
  ScreenShotActiveWindow(Form2.Image1.Picture.BitMap);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Form1.Visible := False;
  ScreenShot(Form2.Image1.Picture.BitMap);
  Form2.Image1.Picture.SaveToFile('C:\bilder\'+Edit1.Text+'.jpg');
  Form1.Edit1.Text:= inttostr(strtoint(Edit1.Text)+1);

end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
   Form1.Timer2.Enabled:= false;
   Form1.Timer1.Enabled:= true;
   Form1.Visible := False;
end;

end.


Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Do 15.01.04 22:40 
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;
Yooda Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 68



BeitragVerfasst: Do 15.01.04 22:54 
Vielen Dank !

Es hat geklappt ! !


Viele Grüsse

David
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Do 15.01.04 23:27 
wie groß ist die Datei in JPG? :mrgreen:
MAlsleben
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 303

W2k,WinXP
D3 - DXE3 Enterprise
BeitragVerfasst: Fr 16.01.04 09:59 
Hi,

mit z.B. jpgfile.CompressionQuality vor Assign kannst Du die Kompression noch verstärken, wobei sich allerdings auch die Qualität ändert.

Gruß Micha.

_________________
Viele Wege führen nach Rom.
Yooda Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 68



BeitragVerfasst: Fr 16.01.04 13:25 
Ich habe die Kompressionsqualität auf 40 gestellt.

Die Bilder sind zwar nicht von sau guter qualität, aber das wollte ich
ja auch net. Nun sind die zwischen 45kb und 80kb (je nach farben).

Aber wo der ein Problem weg ist, da folgt das nächste zugleich ;)
FAlter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 192

Win XP Home
Turbo Delphi 2006 (Win32), C# (VS 2008 Prof.), Java (Eclipse), PHP
BeitragVerfasst: Fr 16.01.04 15:46 
Komisch, dass das jetzt geklappt hat, ich muss dazu vorm Speichern noch jpgfile.Compress aufrufen, sonst wird eine BMP mit Erweiterung JPG gespeichert.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 16.01.04 16:22 
das sollte nicht der Fall sein :?