Is there any way I could creat a custom png loader function or will I have to use a library?
Check whether your OS already has built-in PNG support - if not then get libpng and use that.
You could write your own function if you wanted, by simply implementing something to read the specified file format: ... . However, it's probably way way easier to just use a library for the functionality you want.