Handling .png files in C++
- Download libpng
- Download zlib
- Windows:
- Use the prepared MSVC 6 project and pre-compiled libraries below
- Download the project file
- Test the sample program
- open the test project invert.dsw
- compile and run the project
- check output.png against the web version
- Or:
- Compile libpng and zlib
- Extract libpng
- Extract zlib into the same directory as libpng (they should both be in the same folder)
- open projects\visualc6\libpng.dsw
- compile zlib and libpng projects
- Test the sample program
- download the source code below
- create a new project
- configure the project to use the zlib and libpng libraries you compiled
- compile and run the project
- check output.png against the web version
- Cygwin:
- Run the install tool, and make sure the following packages are installed:
- gcc-g++ (Devel)
- libpng, libpng12, and libpng12-devel (Graphics)
- zlib (Libs)
- Test the sample program
- Compile the test program: g++ -o invert invert.cpp -lz -lpng
- Run the sample program: ./invert facegray.png
- UNIX:
- Try to compile test program g++ -o invert invert.cpp -lz -lpng
- If zlib or libpng not found, compile locally:
- Extract libpng
- Extract zlib into the same directory as libpng (they should both be in the same folder)
- switch to the zlib directory
- run configure you'll need to specify a prefix directory,
for example, configure --prefix=/home/crispy.
- make test
- make install
- switch to the lpng directory
- copy the appropriate makefile (for example, makefile.sunos) from the scripts
directory to the current directory: cp scripts/makefile.cygwin ./makefile
- make -e prefix=/home/crispy test
- make install
- Compile test program: g++ -o invert -Iinclude invert.cpp -L/home/crispy/lib -lpng -lz
- Test the sample program
- ./invert facegray.png
- check output.png against the web version
Programs, Files, Docs
Useful Links