Proper image rendering ux (#5)
* can draw from selection
* add light-weight render manager to render many images simultaneously
* [debug me] currently the image close button does not do
* the unselected image can be closed now
* can close images and manually open them on demand
* cosmetic
* image view stuff in render subdirectory
* cosmetic
* generate docs
* review
windows support
some cosmetics
💅 and pin libCZI module
This commit is contained in:
committed by
Maximilian Kueffner
parent
2990f3313d
commit
bce12b0bb4
@@ -13,5 +13,6 @@ pixelarium::imaging::PixelariumImage::PixelariumImage(const std::string& uri)
|
||||
throw std::runtime_error(std::format("File not {} found", uri));
|
||||
}
|
||||
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
this->img_ = std::make_unique<cv::Mat>(cv::imread(uri));
|
||||
}
|
||||
|
||||
@@ -1,45 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
using AccessorFunctor = std::function<void(const std::string&, void*, int*)>;
|
||||
|
||||
enum class ImageFileType
|
||||
{
|
||||
ABSRACT = 0,
|
||||
PNG = 1,
|
||||
JPG = 2,
|
||||
CZI = 3,
|
||||
};
|
||||
/// @brief This aims to be a generic image abstraction
|
||||
/// meant for codec specific implementation.
|
||||
|
||||
/// Todo: the above implies that most of the below implementations don't make sense for this class (c.f. cv::Mat
|
||||
/// generation et.al.)
|
||||
class PixelariumImage
|
||||
{
|
||||
public:
|
||||
// get back the defaults
|
||||
// this means, that there has to be and API option to set
|
||||
// a resource which should trigger some sort of action
|
||||
// after setting
|
||||
|
||||
explicit PixelariumImage(const std::string& uri);
|
||||
|
||||
// get back the defaults
|
||||
PixelariumImage() = default;
|
||||
PixelariumImage(const PixelariumImage& other)
|
||||
{
|
||||
// be ware!!
|
||||
// we make a copy of the image data here!
|
||||
img_ = std::make_unique<cv::Mat>(*other.img_);
|
||||
uri_ = other.uri_;
|
||||
};
|
||||
PixelariumImage(PixelariumImage&& other) noexcept
|
||||
: img_(std::move(other.img_)) {}
|
||||
// requires a copy ctor which we don't have
|
||||
PixelariumImage(PixelariumImage&& other) noexcept : img_(std::move(other.img_)) {}
|
||||
PixelariumImage& operator=(const PixelariumImage& other) = delete;
|
||||
PixelariumImage& operator=(PixelariumImage&& other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
img_ = std::move(other.img_);
|
||||
uri_ = other.uri_;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
// this should probably vanish as it makes no sense
|
||||
// for multidimensional images (more than one frame)
|
||||
// -> we need some sort of accessor functionality
|
||||
|
||||
~PixelariumImage() = default;
|
||||
|
||||
const cv::Mat& GetImage() const { return *this->img_.get(); }
|
||||
|
||||
const std::string Name() const noexcept
|
||||
{
|
||||
if (!this->uri_.empty())
|
||||
{
|
||||
return this->uri_.filename().string();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Empty() const noexcept { return this->img_->empty(); }
|
||||
|
||||
static ImageFileType Type() { return PixelariumImage::type_; }
|
||||
|
||||
protected:
|
||||
std::unique_ptr<cv::Mat> img_;
|
||||
|
||||
std::filesystem::path uri_;
|
||||
|
||||
static ImageFileType type_;
|
||||
};
|
||||
|
||||
} // namespace pixelarium::imaging
|
||||
|
||||
Reference in New Issue
Block a user