Gerneric image codec abstraction init (#6)
* remove raw pointer from resource manager
* towards generic images
* 💅 and pin libCZI module
* remove raw pointer from resource manager
* towards generic images
* fix rendering
* fix rendering
* fix unit tests
* fix pipeline
* fix gcc build
* re-enable tests
* add czi impl
* remove resource button
* refactor user code app to being a "default app"
* ui resources
* missing lib?
* init czi render support
* typos
This commit is contained in:
committed by
Maximilian Kueffner
parent
bce12b0bb4
commit
0be064bb8e
@@ -0,0 +1,34 @@
|
||||
#include "PixelariumPng.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <string>
|
||||
|
||||
pixelarium::imaging::PixelariumPng::PixelariumPng(const std::string& uri)
|
||||
{
|
||||
if (!std::filesystem::exists(uri))
|
||||
{
|
||||
throw std::runtime_error("Render file not found.");
|
||||
}
|
||||
|
||||
this->is_empty_ = false;
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumPng::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