0

这个基本示例在具有相同 TGA 文件的 macOS 上工作,但由于某种原因,在具有此特定文件的 Windows 上,输出与提供的图像中一样。

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());

地球.tga:

地球.tga

输出.tga:

在此处输入图像描述

我尝试过的其他 tga 文件工作正常。与 Windows 上的 ifstream 有什么区别可能会导致问题?你可以在这里找到 tga https://people.math.sc.edu/Burkardt/data/tga/tga.html

4

0 回答 0