This is a stripped down copy of loadpng 0.11
