Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decompress PNG using zlib

Tags:

c

gcc

zlib

png

How can I use zlib library to decompress a PNG file? I need to read a PNG file using a C under gcc compiler.

like image 820
name_masked Avatar asked Oct 26 '25 10:10

name_masked


2 Answers

Why not use libpng? The PNG file format is fairly simple, but there are many different possible variations and encoding methods and it can be fairly tedious to ensure you cover all of the cases. Something like libpng handles all the conversion and stuff for you automatically.

like image 110
Dean Harding Avatar answered Oct 28 '25 23:10

Dean Harding


I've code once a basic Java library for reading/writing PNG files: http://code.google.com/p/pngj/

It does not support palleted images but apart from that[Updated: it supports all PNG variants now] it's fairly complete, simple and the code has no external dependencies (i.e. it only uses the standard JSE API, which includes zip decompression). And the code is available. I guess you could port it to C with not much effort.

like image 43
leonbloy Avatar answered Oct 29 '25 00:10

leonbloy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!