Enhance image type support (#18)
* adds tiff support * doc update * adds memory-based =IPixelariumImage= implementation * add usage example for custom user control * enhance * clang-format fix readme fix docs
This commit is contained in:
committed by
Maximilian Kueffner
parent
356f966d01
commit
e3e161ce52
@@ -0,0 +1,34 @@
|
||||
#include "PixelariumTiff.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <string>
|
||||
|
||||
pixelarium::imaging::PixelariumTiff::PixelariumTiff(const std::string& uri, const Log& log) : log_(log)
|
||||
{
|
||||
if (!std::filesystem::exists(uri))
|
||||
{
|
||||
throw std::runtime_error("Render file not found.");
|
||||
}
|
||||
|
||||
this->is_empty_ = false;
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumTiff::TryGetImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
auto img = std::make_unique<cv::Mat>(cv::imread(this->uri_.string()));
|
||||
|
||||
this->is_empty_ = false;
|
||||
|
||||
return img;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
this->is_empty_ = true;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user