From d6663fe7b71db340b3c7a1d069c473f725caa3a8 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 29 Aug 2022 12:19:25 -0400 Subject: Trying to support the superior operating system. Also reformat a bit of legacy code. Smells like mold. --- imageutil.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'imageutil.cpp') diff --git a/imageutil.cpp b/imageutil.cpp index b3609d4..fd78ccf 100644 --- a/imageutil.cpp +++ b/imageutil.cpp @@ -1,8 +1,12 @@ #include #include +#include #include #include //#include + +#include + #include "imageutil.hpp" //libpuzzle uses a contrast-based cropping, and clamps the cropped area to a given percentage. @@ -111,3 +115,15 @@ cv::Mat image_util::blend_white(cv::Mat m) } return ret; } + +cv::Mat image_util::imread_path(const std::filesystem::path &p, int flags) +{ + auto size = std::filesystem::file_size(p); + std::fstream fst(p, std::ios::binary | std::ios::in); + std::vector dat; + dat.resize(size); + fst.read(dat.data(), size); + fst.close(); + cv::Mat img = cv::imdecode(dat, flags); + return img; +} -- cgit v1.2.3