kikuchan / pngle

Pngle - PNG Loader for Embedding
MIT License
109 stars 20 forks source link

"Failed to decompress the IDAT stream" on the TI 84 Plus CE #12

Closed TheMiningTeamYT closed 4 weeks ago

TheMiningTeamYT commented 1 month ago

I'm attempting to use PNGLE to add PNG support to my USB image viewer for the TI 84 Plus CE, BMP84CE. However, after calling pngle_feed I'm getting the error Failed to decompress the IDAT stream. From debug_printf, I'm also getting the message [pngle] tinfl_decompress() failed with status -1! The code of tinfl_decompress is too dense for me to read, so I was hoping I could get some help. You can see my code here. (in particular, I'm invoking PNGLE here.) FYI, the TI 84 Plus CE uses a 24 bit (yes, 24 bit!) eZ80, meaning int and unsigned int are 24 bits wide, not 32 bits wide. I already had to fix the mz_uint32 types in miniz, and the read_uint32 function in PNGLE because of this. Hope this helps you figure out what's going wrong. If you have any questions, please ask.

TheMiningTeamYT commented 4 weeks ago

Okay, I figured out what's going on. The TI 84 Plus CE toolchain compiler doesn't like this macro: https://github.com/kikuchan/pngle/blob/8bf3862f84a4643e75a7d92e046d7c07f934cead/src/miniz.c#L1382 It was incrementing the pointer more than it should, which was causing the ZLIB header to get read incorrectly. I changed it to this: https://github.com/TheMiningTeamYT/Bitmap84CE/blob/74a767bcd400b4a32cf7cbd153d931b57e1abf44/src/pngle/miniz.c#L1393 and it started working. (This is also easier to read IMO.)

kikuchan commented 4 weeks ago

Thank you for using pngle! And congrats for your code working now. I'm happy to hear that.

Yeah, the miniz is too dense, and maybe it's too old. I think it should be updated to the latest version, or use another library, in time.