You also need to install the -dev packages if you do software development (what you already did, if you ran the command from your link).
libpng12-0:
This package contains the runtime library files needed to run software using libpng.
libpng12-dev
This package contains the header and development files needed to build programs and packages using libpng.
Furthermore, in Code::Blocks right-click on the projectname in the projects-tree, and select "Build options...". In the upcoming window select the top of the tree on the left side (you project name). In the mainpart of the window select "Linker settings". In the left listbox add an entry with the name
libpng
Now your project should compile fine.
