Autor Beitrag
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 28.10.02 14:02 
Wie kann ich einen Stream, den ich mit einem TCompressionStream aus der Unit ZLIB komprimiert habe wider dekomprimieren?
Es gibt einen TDecompressionstream mit eine Methode Read; nur wenn ich die verwende, bekomme ich keinen gescheiten Output, besser gesagt ich bekomme immer das gleich Ergebnis, egal was ich reinschreibe.

Hat jemand damit erfahrung?

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 28.10.02 15:32 
Meine Lesen-Routine sieht bisher so aus:

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:
27:
28:
29:
procedure TForm1.btnUnZIPClick(Sender: TObject);
var ZIPStream: TDecompressionStream;
    SrcStream: TMemoryStream;
    Buffer: string[200];
    s: string;

    size : integer;
begin
  SrcStream := TMemoryStream.Create;
  SrcStream.LoadFromFile(ExtractFilePath(Application.Exename)+'Test.file');
  ZIPStream := TDecompressionStream.Create(SrcStream);

  Size := SrcStream.Size;

  ZIPStream.Seek(0,soFromBeginning);

  s := '';
  while ZIPStream.Position < ZIPStream.Size do begin
    Buffer := '';
    ZIPStream.ReadBuffer(Buffer,200);
    s := s+Buffer;
    dec(size,200);
    ZipStream.Seek(0,soFromCurrent);
  end;

  ZIPStream.Free;
  SrcStream.Free;
  Memo1.Text := s;
end;


Allerdings bekomme ich dabei die Exception:
Invalid Stream operation. Read from Adress $FFFFFF

Ich frag mich nur warum?
Wenn ich ZIPStream.Position < ZIPStream.Size abfrage müsste ich doch herausinden, ob ich am Ende vom Stream bin oder nicht.
:roll: :?: :( :?:

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?