This:
ifstream image("bg.png");
… opens the file in text mode, where, in Windows and on old Macs, certain byte sequences denoting end-of-line and end-of-text, are changed on input and output.
You don’t want that.
That said, the closest you get to “standard” image handling in C++ is the Boost Image library.