There's only so many things that can go wrong here. Either the working directory is wrong (if you're only passing filename and not a full path), or there is something incorrect in the path being used. Maybe you are using single \ or something.
The FILE pointer is NULL when I call fopen. I have tried to load five different images, and they all return NULL after calling IMG_Load. However, I have a text file in my game, and that file loads. It's just the PNG files that don't load. The text file is in the application directory, just like the PNG files.
- What's the name of the file and it's full path on your computer? Does it use any non-english characters?
- What is the working directory when you attempt to open it?
- And what is the contents of the variable "filename" when you pass it to fopen?