Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: Weps on February 20, 2019, 05:36:28 am

Title: [Solved] Decompression error when loading png (no issues in other applications).
Post by: Weps on February 20, 2019, 05:36:28 am
Code: Pascal  [Select][+][-]
  1. var
  2.   p: TPortableNetworkGraphic;
  3. begin
  4.   p := TPortableNetworkGraphic.Create;
  5.   try
  6.    p.LoadFromFile( './error.png');
  7.  
  8.   except
  9.     on e: exception do begin
  10.       showmessage( e.message);
  11.     end;
  12.   end;
  13.  

throws a "data error".

This is coming from zinflate.pas lines 438-445

Code: Pascal  [Select][+][-]
  1.         if (z.state^.sub.check.was <> z.state^.sub.check.need) then
  2.         begin
  3.           z.state^.mode := BAD;
  4.           z.msg := 'incorrect data check';
  5.           z.state^.sub.marker := 5;       { can't try inflateSync }
  6.           continue;           { break C-switch }
  7.         end;
  8.  

I have no idea why this png would fail. I ran the PNG checker and PNG analyzer, both report no errors. Nor does any other tool so far (browsers, linux).

Is this an error in the zlib code of fpc? Or what is going wrong with this png file?


(Lazarus 1.8.4 / FPC 3.0.4 / SVN 57952 / win64)

Title: Re: Decompression error when loading png (no issues in other applications).
Post by: Weps on February 20, 2019, 06:12:12 am

It seems there were some changes to the zlib library, and I found this one (eventually):

https://bugs.freepascal.org/view.php?id=33493

1.8.4 did not include this fix, I copied it manually, and the png loads correctly.


Time to move to 2.0 I suppose...
Title: Re: Decompression error when loading png (no issues in other applications).
Post by: zeljko on February 20, 2019, 09:26:01 am
Lazarus 2.0 won't help in this case. That patch is for fpc-3.2.0 and fpc-trunk
Title: Re: Decompression error when loading png (no issues in other applications).
Post by: Weps on February 20, 2019, 02:50:48 pm
Good to know. Thanks.
TinyPortal © 2005-2018