Resources (#1)

* start some resource fiddling

* start some resource fiddling

* initiate a real resource manager

* fix color flicker in rendering

* delete unintended constructors

and add a convenience function to reset the render-image (from the
original image, aka. clone again)

* [OpenGL deprecation warning]

The compiler said that these functions are "deprecated". They seem to
be useless anyway...

* various improvements

* add resource enumerator and documentation

* fix constness stuff

* use existing iterator for insertion

* init unit tests

* rm bogus file

---------

Co-authored-by: m-aXimilian <keuffnermax@gmail.com>
This commit is contained in:
m-aXimilian
2025-06-13 22:23:20 +00:00
committed by GitHub
parent a175b79c96
commit a8489292b6
21 changed files with 574 additions and 169 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ message(STATUS "Found opencv: " ${OpenCV_INCLUDE_DIRS})
message(STATUS "OpenCV_LIBs from: " ${OpenCV_LIBS})
set(IMAGELIBSRC
Image.cpp)
PixelariumImage.cpp)
set(IMAGELIBLIBNAME pixelariumimagelib)
@@ -20,4 +20,4 @@ target_link_libraries(${IMAGELIBLIBNAME}
target_include_directories(${IMAGELIBLIBNAME}
PUBLIC ${OpenCV_INCLUDE_DIRS}
PRIVATE ${LIBCZI_INCLUDE_DIR})
PRIVATE ${LIBCZI_INCLUDE_DIR})
-31
View File
@@ -1,31 +0,0 @@
#pragma once
#include <memory>
#include <opencv2/core/mat.hpp>
#include <string>
namespace pixelarium::imaging
{
class Image
{
public:
explicit Image(const std::string& uri);
// get back the defaults
Image() = default;
// we cannot copy an Image since this conflicts with the _img field
Image(const Image& other) = delete;
Image(Image&& other) noexcept = default;
// requires a copy ctor which we don't have
Image& operator=(const Image& other) = delete;
Image& operator=(Image&& other) noexcept = default;
~Image() = default;
const cv::Mat& GetImage() const { return *this->_img.get(); }
private:
std::unique_ptr<cv::Mat> _img;
};
} // namespace pixelarium::imaging
@@ -1,18 +1,17 @@
#include "Image.hpp"
#include "PixelariumImage.hpp"
#include <filesystem>
#include <format>
#include <memory>
#include <opencv2/imgcodecs.hpp>
#include <stdexcept>
#include <string_view>
pixelarium::imaging::Image::Image(const std::string& uri)
pixelarium::imaging::PixelariumImage::PixelariumImage(const std::string& uri)
{
if (!std::filesystem::exists(uri))
{
throw std::runtime_error(std::format("File not {} found", uri));
}
this->_img = std::make_unique<cv::Mat>(cv::imread(uri));
}
this->img_ = std::make_unique<cv::Mat>(cv::imread(uri));
}
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include <memory>
#include <opencv2/core/mat.hpp>
#include <string>
namespace pixelarium::imaging
{
class PixelariumImage
{
public:
explicit PixelariumImage(const std::string& uri);
// get back the defaults
PixelariumImage() = default;
// we cannot copy an Image since this conflicts with the _img field
PixelariumImage(const PixelariumImage& other) = delete;
PixelariumImage(PixelariumImage&& other) noexcept
: img_(std::move(other.img_)) {}
// requires a copy ctor which we don't have
PixelariumImage& operator=(const PixelariumImage& other) = delete;
PixelariumImage& operator=(PixelariumImage&& other) noexcept
{
if (this != &other)
{
img_ = std::move(other.img_);
}
return *this;
}
~PixelariumImage() = default;
const cv::Mat& GetImage() const { return *this->img_.get(); }
protected:
std::unique_ptr<cv::Mat> img_;
};
} // namespace pixelarium::imaging