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
This commit is contained in:
m-aXimilian
2025-09-23 21:57:08 +02:00
committed by Maximilian Kueffner
parent 0be064bb8e
commit 235d00192a
34 changed files with 418 additions and 173 deletions
+22 -21
View File
@@ -61,24 +61,30 @@ GLuint pixelarium::render::CvMatRender::uploadTexture()
glBindTexture(GL_TEXTURE_2D, this->texture_);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
const int width = img_.cols;
const int height = img_.rows;
GLenum format = (img_.type() == CV_32FC3 || img_.type() == CV_32FC1) ? GL_RGB : GL_RGBA;
GLenum type = (img_.type() == CV_16U || img_.type() == CV_16UC3) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
GLenum internalFormat = GL_RGBA;
if (img_.type() == CV_32FC3 || img_.type() == CV_32FC1)
{
internalFormat = GL_RGB;
switch (img_.type()) {
case CV_16U:
case CV_16UC3:
case 26:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, img_.data);
break;
case 5:
case 29:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, img_.data);
break;
default:
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_.cols, img_.rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, img_.data);
break;
}
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, img_.data);
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
@@ -98,9 +104,9 @@ GLuint pixelarium::render::CvMatRender::Render() { return this->uploadTexture();
GLuint pixelarium::render::CvMatRender::Render(float factor)
{
auto res_val {this->base_->TryGetImage()};
if (res_val.has_value())
if (res_val)
{
cv::resize(*res_val.value(), this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
cv::resize(*res_val, this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
}
return this->uploadTexture();
@@ -114,12 +120,12 @@ GLuint pixelarium::render::CvMatRender::Render(size_t width, size_t height)
{
auto res_val {this->base_->TryGetImage()};
if (!res_val.has_value())
if (!res_val)
{
return this->Render(1.0f);
}
const auto sz{res_val.value()->size()};
const auto sz{res_val->size()};
const auto get_factor = [](auto opt1, auto opt2) -> float { return opt1 < opt2 ? opt1 : opt2; };
@@ -137,16 +143,11 @@ void pixelarium::render::CvMatRender::ResetRenderImage()
auto root_res = this->base_->TryGetImage();
if (!root_res.has_value())
{
return;
}
if (root_res.value() == nullptr)
if (!root_res)
{
return;
}
// we copy here
this->img_ = (*root_res.value()).clone();
this->img_ = root_res->clone();
}