2025-09-22 23:13:28 +02:00
|
|
|
#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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-23 21:57:08 +02:00
|
|
|
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumPng::TryGetImage()
|
2025-09-22 23:13:28 +02:00
|
|
|
{
|
|
|
|
|
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 {};
|
|
|
|
|
}
|
|
|
|
|
}
|