This basic example is working on macOS with the same TGA file but for some reason on windows with this particular file the output is as in the provided image.
std::ifstream input_file("C:\\Users\\Michael\\Desktop\\earth.tga", std::ios::binary);
input_file.seekg(0, std::ios::end);
std::size_t length = input_file.tellg();
input_file.seekg(0, std::ios::beg);
std::vector<char> data(length);
input_file.read(data.data(), length);
std::ofstream output_file("C:\\Users\\Michael\\Desktop\\output.tga", std::ofstream::out);
output_file.write(data.data(), data.size());
earth.tga:
output.tga:
Other tga files that I've tried work fine. What difference with ifstream on windows could be causing the issue? You can find the tga here https://people.math.sc.edu/Burkardt/data/tga/tga.html