Czi rendering (#10)
* add dimension selector sliders to czi view * version doc & version bump * cosmetic * fix build? * multi-dimension selection enabled in czi view * remove the parameterized reset function of the renderer it is not and is conceptually questionable doc updates & some minor improvements auto-update CZI-view when sliders are moved set initial window size fix windows build and msvc build For reasons I don not comprehend, on Windows, we must include =opencv2/core/mat.hpp= as the very last header in the =CvMatRender.hpp=. If this is at any other position building on Windows, compilation will break w/ all kinds of cryptic errors regarding OpenCV. When building w/ msvc =__PRETTY_FUNCTION__= is not defined. =ILog.hpp= now defines it. This should be revised to only be set when the compiler is msvc. For the time being, it is considered sufficient though.
This commit is contained in:
committed by
Maximilian Kueffner
parent
e60203b57d
commit
1ea83d9d11
@@ -1,9 +1,7 @@
|
||||
#include "CvMatRender.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "imaging/IPixelariumImage.hpp"
|
||||
|
||||
@@ -11,7 +9,7 @@ using namespace pixelarium::imaging;
|
||||
|
||||
/// @brief Constructor for the CvMatRender class.
|
||||
/// @param img A shared pointer to the PixelariumImage to be rendered.
|
||||
pixelarium::render::CvMatRender::CvMatRender(std::shared_ptr<pixelarium::imaging::IPixelariumImage>& img) : base_(img), texture_(0)
|
||||
pixelarium::render::CvMatRender::CvMatRender(const cv::Mat& img) : base_(img), texture_(0)
|
||||
{
|
||||
// storing a copy of the to-be-rendered image
|
||||
// because it will be resized and filtered eventually which we absolutely
|
||||
@@ -31,15 +29,6 @@ pixelarium::render::CvMatRender::~CvMatRender()
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Resets the render image with a new PixelariumImage.
|
||||
/// @param img A shared pointer to the new PixelariumImage.
|
||||
void pixelarium::render::CvMatRender::ResetRenderImage(std::shared_ptr<pixelarium::imaging::IPixelariumImage>& img)
|
||||
{
|
||||
this->base_ = img;
|
||||
this->ResetRenderImage();
|
||||
cv::cvtColor(this->img_, this->img_, cv::COLOR_BGR2RGBA);
|
||||
}
|
||||
|
||||
/// @brief Uploads the current image data to an OpenGL texture.
|
||||
/// @return The ID of the uploaded OpenGL texture.
|
||||
/// @throws std::runtime_error if the image data is empty or if there is an OpenGL error.
|
||||
@@ -103,11 +92,7 @@ GLuint pixelarium::render::CvMatRender::Render() { return this->uploadTexture();
|
||||
/// @return The ID of the OpenGL texture.
|
||||
GLuint pixelarium::render::CvMatRender::Render(float factor)
|
||||
{
|
||||
auto res_val {this->base_->TryGetImage()};
|
||||
if (res_val)
|
||||
{
|
||||
cv::resize(*res_val, this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
|
||||
}
|
||||
cv::resize(this->base_, this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
|
||||
|
||||
return this->uploadTexture();
|
||||
}
|
||||
@@ -118,14 +103,7 @@ GLuint pixelarium::render::CvMatRender::Render(float factor)
|
||||
/// @return The ID of the OpenGL texture.
|
||||
GLuint pixelarium::render::CvMatRender::Render(size_t width, size_t height)
|
||||
{
|
||||
auto res_val {this->base_->TryGetImage()};
|
||||
|
||||
if (!res_val)
|
||||
{
|
||||
return this->Render(1.0f);
|
||||
}
|
||||
|
||||
const auto sz{res_val->size()};
|
||||
const auto sz{this->base_.size()};
|
||||
|
||||
const auto get_factor = [](auto opt1, auto opt2) -> float { return opt1 < opt2 ? opt1 : opt2; };
|
||||
|
||||
@@ -136,18 +114,6 @@ GLuint pixelarium::render::CvMatRender::Render(size_t width, size_t height)
|
||||
|
||||
void pixelarium::render::CvMatRender::ResetRenderImage()
|
||||
{
|
||||
if (this->base_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto root_res = this->base_->TryGetImage();
|
||||
|
||||
if (!root_res)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we copy here
|
||||
this->img_ = root_res->clone();
|
||||
this->img_ = this->base_.clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user