[fpc-devel] zstream, fpc and lazarus

Paul Ishenin webpirat at mail.ru
Sun Dec 2 10:16:22 CET 2007

Daniƫl Mantione wrote:
> Please copy/paste that help. I can't believe that one would demand that 
> a zstream starts from the start of a file; I know no file format which 
> works this way, not even gzip.
delphi help:
"You can call the Seek method with an Offset of zero, and the Origin set 
to soFromBeginning. This has the effect of resetting the input stream, 
effectively rewinding the stream back to the beginning."
> How does it work in Lazarus? A PNG file does not start with a zstream, it 
> is in the middle of the file. If you seek to the start of a PNG file, you 
> will read PNG chunks rather than a Zstream.
paste from fcl-image\src\fpreadpng.pp:

  ZData := TMemoryStream.Create;
    EndOfFile := false;
    while not EndOfFile do
    Decompress := TDecompressionStream.Create (ZData);
      Decompress.position := 0;

So it uses memory stream. It writes data to ZData memory stream, then 
creates TDecompressionStream. Do you see ZData.Position = 0 here? I 
dont. Code assume that TDecompressionStream.Create will do that. But 
TDecompressionStream skips that => we have crash.

Best regards,
Paul Ishenin.

More information about the fpc-devel mailing list