Files
pixelarium/lib/imaging/impl/PixelariumJpg.cpp
T

33 lines
659 B
C++
Raw Normal View History

2025-09-22 23:13:28 +02:00
#include "PixelariumJpg.hpp"
#include <opencv2/imgcodecs.hpp>
#include <string>
pixelarium::imaging::PixelariumJpg::PixelariumJpg(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);
}
2026-01-23 23:00:35 +00:00
std::optional<cv::Mat> pixelarium::imaging::PixelariumJpg::TryGetImage()
2025-09-22 23:13:28 +02:00
{
try
{
2026-01-23 23:00:35 +00:00
auto img = cv::Mat(cv::imread(this->uri_.string()));
2025-09-22 23:13:28 +02:00
this->is_empty_ = false;
return img;
}
catch (const std::exception& e)
{
this->is_empty_ = true;
return {};
}
}