Autor Beitrag
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Do 08.05.03 20:52 
Ich würde gerne mit einer Progressbar den Status angeben, während eine große Datei mit der Delphi Fast Zlib v.1.1.2 Unit De-/Komprimiert wird. Dazu habe ich mal folgendes probiert:
ausblenden Quelltext
1:
2:
3:
4:
5:
    CStream := TZCompressionStream.Create(m);
    CStream.OnProgress := ZipOnProgress;
    CStream.CopyFrom(InpStream, InpStream.Size);
    CStream.Free;
    m.SaveToStream(OutStream);


Doch leider wird dann ZipOnProgress nich ein einziges mal aufgerufen. Wer kann mir helfen? Ist ein bisschen doof, den User ne Minute ohne Statusmeldung rumhocken zu lassen.

edit: ich hab so das unbestimmte Gefühl, dass ich mich wohl im Thread verklickt habe...

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Do 08.05.03 23:15 
also bei mir gehtz...

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Procedure TForm1.MyProgress(Sender: TObject);
Begin
  ProgressBar1.Position := (Sender as TCompressionStream).Position;
End;

procedure TForm1.Button1Click(Sender: TObject);
Var sStream: TFileStream;
    cStream: TCompressionStream;
    dStream: TFileStream;
begin
  sStream := TFileStream.Create('i:\i.bin', fmOpenRead);
  dStream := TFileStream.Create('i:\j.bin', fmCreate);
  cStream := TCompressionStream.Create(clFastest, dStream);
  Try
    cStream.OnProgress := MyProgress;
    ProgressBar1.Max := sStream.Size; // wichtig!!
    cStream.CopyFrom(sStream, sStream.Size);
  Finally
    sStream.Free;
    dStream.Free;
  End;
end;


wenn die compression bei dir aber ne minute dauert, dann solltest du das ganze in nen anderen thread legen. dann wird dein fenster auch neu gemalt. nur so als hinweis.


ase

_________________
-EN
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Fr 09.05.03 14:52 
Kann das sein, das du nicht die DelphiFastZLib benutzt, da bei mir die Klasse TZCompressionStream heißt? Funktionieren tut es auf jedenfall immer noch nicht. Werds mal mit der BZip probieren :? .
Ich wollte so oder so einen Thread benutzen, da ich dem Benutzer auch die Möglichkeit geben wollte, den Prozess abzubrechen.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Fr 09.05.03 15:01 
ups... hehe... wieß nich... hab einfach zlib eingebunden :nixweiss:


ase

_________________
-EN
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Fr 09.05.03 15:04 
Ok, mit der BZLib oder BZip? funktioniert zwar die Statusmeldung, aber die komprimierung ist dermaßen a**** langsam...

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Fr 09.05.03 15:09 
und warum nimmst du nich die zlib?

_________________
-EN
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Fr 09.05.03 15:11 
Da die vom mir verwendete Delphi Fast ZLib schneller ist. Baut aber auch auf der ZLib auf.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Fr 09.05.03 15:14 
Problem gelöst. In der Unit war ein kleiner Bug drin:
ausblenden 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:
function TZCompressionStream.Write(const buffer; count: Longint): Longint;
begin
  FZStream.next_in := @buffer;
  FZStream.avail_in := count;

  if FStream.Position <> FStreamPos then FStream.Position := FStreamPos;

  while FZStream.avail_in > 0 do
  begin
    ZCompressCheck(deflate(FZStream, Z_NO_FLUSH));

    if FZStream.avail_out = 0 then
    begin
      FStream.WriteBuffer(FBuffer, SizeOf(FBuffer));

      FZStream.next_out := FBuffer;
      FZStream.avail_out := SizeOf(FBuffer);

      FStreamPos := FStream.Position;
      //hier stand mal DoProgress;
    end;
    DoProgress; //hier stehts jetzt
  end;

  result := Count;
end;


Anmerkung: Der letzte Post von ase bezieht sich auf den Artikel darüber. Dies ist also praktisch der aktuelleste Artikel des Threads.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...


Zuletzt bearbeitet von O'rallY am Sa 10.05.03 11:58, insgesamt 1-mal bearbeitet
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Fr 09.05.03 15:14 
tja dann... musst du des entscheiden. wenn es jetzt geht aber langsam ist, dann würde ich das ganze als abgeschlossen betrachten.


ase

_________________
-EN