Fix Image::WriteBinary() writing values to a file one at a time.

PiperOrigin-RevId: 767955187
This commit is contained in:
Rhett Stucki 2025-06-06 00:47:29 -07:00 committed by Copybara-Service
parent 6ee628ba38
commit 824a95793c
1 changed files with 2 additions and 3 deletions

View File

@ -201,9 +201,8 @@ bool Image::WriteBinary(const std::string& filename) const {
std::cerr << "Failed to open " << filename << "\n"; std::cerr << "Failed to open " << filename << "\n";
return false; return false;
} }
for (size_t i = 0; i < data_.size(); ++i) { file.write(reinterpret_cast<const char*>(data_.data()),
file.write(reinterpret_cast<const char*>(&data_[i]), sizeof(float)); data_.size() * sizeof(data_[0]));
}
file.close(); file.close();
return true; return true;
} }