Files
pixelarium/lib/imaging/impl/PixelariumPng.cpp
T
m-aXimilian 235d00192a Misc Improvements (#7)
* get rid of optional<ptr> -> double indirection

* more optional cleanup

* fix

* add more render pixel type options

* towards different views

* missing virtual declaration of ShowImage

* fix runtime

* init image view factory

* fix build

Render Image close button re-enable

add readme

init documentation

use awesomeDoxygen

ci build docs

install doxygen

id token permission

add pages write permission
2026-02-16 20:36:48 +01:00

35 lines
719 B
C++

#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::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 {};
}
}