* get image returns optional<Mat> instead of unique_ptr<Mat>

* introduce complexity

* rename image load function

* add example for a basic reader for binary image files

* fix windows build?

* add a status bar underneath the menu bar

* use status bar in custom_0 example app

* clang formats

* packing w/ pragma push

* add "Save As" functions to image views

* resize over reserve

* rm local override uri

* add simple thread pool

* rename to simple_thread_pool

* get rid of useless renderlib

* document version inc

* extract hardcoded values to in-header

* clang format patch

* clone registered image in custom_0

* document binary-file header

* minor fixes

* clang format

* rm unused render cmake
This commit is contained in:
m-aXimilian
2026-01-23 23:00:35 +00:00
committed by Maximilian Kueffner
parent e3e161ce52
commit b37814204f
52 changed files with 712 additions and 207 deletions
+10 -8
View File
@@ -4,6 +4,8 @@
#include <filesystem>
#include <format>
#include <memory>
#include <opencv2/imgcodecs.hpp>
#include <optional>
#include <stdexcept>
#include <utility>
@@ -48,8 +50,8 @@ constexpr int try_get_index_match(const pixelarium::imaging::CziParams& params,
return index;
}
std::unique_ptr<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData> bitmap, libCZI::PixelType pixeltype,
const pixelarium::utils::log::ILog& log)
std::optional<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData> bitmap, libCZI::PixelType pixeltype,
const pixelarium::utils::log::ILog& log)
{
size_t pixel_size{0};
int target_type;
@@ -94,21 +96,21 @@ std::unique_ptr<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData>
break;
}
if (pixel_size < 0) return nullptr;
if (pixel_size < 0) return std::nullopt;
log.Info(std::format("{}: source pixel type {}, target cv pixel type {}, pixel size {}", __PRETTY_FUNCTION__,
pixel_pair.first, pixel_pair.second, pixel_size));
size_t height{bitmap->GetHeight()};
size_t width{bitmap->GetWidth()};
auto fill_mat = std::make_unique<cv::Mat>(height, width, target_type);
auto fill_mat = cv::Mat(height, width, target_type);
auto bitmap_info = bitmap->Lock();
for (size_t h{0}; h < height; ++h)
{
unsigned char* source_row = ((unsigned char*)bitmap_info.ptrDataRoi) + bitmap_info.stride * h;
unsigned char* target_row = fill_mat->ptr(h);
unsigned char* target_row = fill_mat.ptr(h);
for (size_t w{0}; w < width; ++w)
{
@@ -139,7 +141,7 @@ std::unique_ptr<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData>
return fill_mat;
}
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::SubblockToCvMat(int index)
std::optional<cv::Mat> pixelarium::imaging::PixelariumCzi::SubblockToCvMat(int index)
{
log_.Info(std::format("{}: constructing bitmap with index {}", __PRETTY_FUNCTION__, index));
auto block = this->czi_reader_->ReadSubBlock(index);
@@ -170,9 +172,9 @@ pixelarium::imaging::PixelariumCzi::PixelariumCzi(const std::string& uri, const
});
}
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage() { return SubblockToCvMat(0); }
std::optional<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage() { return SubblockToCvMat(0); }
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage(const IImageQuery& query)
std::optional<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage(const IImageQuery& query)
{
const auto czi_query = static_cast<const CziParams&>(query);
int index = try_get_index_match(czi_query, *this->czi_reader_);