diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-10-31 23:46:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-10-31 23:46:27 +0100 |
| commit | 0efeb7c04566961b7d2d0745b63bc92f7f5b3b61 (patch) | |
| tree | a3316cc4aa0603c04f991cf769e377f697f8fe1c /test | |
| parent | 452e4844326048da0f1fdc8dbf623b43cb400798 (diff) | |
Add a method to write a raw "openjpeg" image to a file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 16 | ||||
| -rw-r--r-- | test/test.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/test.cc b/test/test.cc index 02b567237..049d74676 100644 --- a/test/test.cc +++ b/test/test.cc @@ -1004,3 +1004,19 @@ Editor::replace(string a, string b) boost::algorithm::replace_all(_content, a, b); BOOST_REQUIRE(_content != old_content); } + + +void +write_openjpeg_image(shared_ptr<const dcp::OpenJPEGImage> image, boost::filesystem::path path) +{ + dcp::File output(path, "wb"); + + auto size = image->size(); + output.checked_write(&size.width, sizeof(size.width)); + output.checked_write(&size.height, sizeof(size.height)); + + for (int c = 0; c < 3; ++c) { + output.checked_write(image->data(c), size.width * size.height * sizeof(int)); + } +} + diff --git a/test/test.h b/test/test.h index 8bcef0604..ab3e90a3a 100644 --- a/test/test.h +++ b/test/test.h @@ -77,6 +77,7 @@ extern void make_and_verify_dcp (std::shared_ptr<Film> film, std::vector<dcp::Ve extern void check_int_close (int a, int b, int d); extern void check_int_close (std::pair<int, int>, std::pair<int, int>, int d); extern boost::filesystem::path find_file (boost::filesystem::path dir, std::string filename_part); +void write_openjpeg_image(std::shared_ptr<const dcp::OpenJPEGImage> image, boost::filesystem::path path); class LogSwitcher |
