Oh yeah, you are aware that Free Pascal has a unit for the libpng library? It's called 'png'. It compiles fine with your test program, as long as I add the -lm parameter. I guess you also want Delphi compatibility, though.