Add a method to write a raw "openjpeg" image to a file.
authorCarl Hetherington <cth@carlh.net>
Mon, 31 Oct 2022 22:46:27 +0000 (23:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 31 Oct 2022 22:46:27 +0000 (23:46 +0100)
test/test.cc
test/test.h

index 02b567237b01dd20f9d4251686172872689af442..049d74676fd3742a40ac97e897e5ff6b21cdc2a1 100644 (file)
@@ -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));
+       }
+}
+
index 8bcef0604c9b3a080a839735b4e034dc0bc45900..ab3e90a3ac9bf070e7ca1e49cc5e80b363f52095 100644 (file)
@@ -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