Recent

Author Topic: [Solved] Decompression error when loading png (no issues in other applications).  (Read 1013 times)

Weps

  • New Member
  • *
  • Posts: 12
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)

« Last Edit: March 26, 2019, 12:49:43 pm by Weps »

Weps

  • New Member
  • *
  • Posts: 12
Re: Decompression error when loading png (no issues in other applications).
« Reply #1 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...

zeljko

  • Hero Member
  • *****
  • Posts: 1080
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Decompression error when loading png (no issues in other applications).
« Reply #2 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

Weps

  • New Member
  • *
  • Posts: 12
Re: Decompression error when loading png (no issues in other applications).
« Reply #3 on: February 20, 2019, 02:50:48 pm »
Good to know. Thanks.