Gerneric image codec abstraction init (#6)

* remove raw pointer from resource manager

* towards generic images

* 💅 and pin libCZI module

* remove raw pointer from resource manager

* towards generic images

* fix rendering

* fix rendering

* fix unit tests

* fix pipeline

* fix gcc build

* re-enable tests

* add czi impl

* remove resource button

* refactor user code app to being a "default app"

* ui resources

* missing lib?

* init czi render support

* typos
This commit is contained in:
m-aXimilian
2025-09-22 23:13:28 +02:00
committed by Maximilian Kueffner
parent bce12b0bb4
commit 0be064bb8e
31 changed files with 670 additions and 221 deletions
+14 -8
View File
@@ -2,6 +2,7 @@
#include <format>
#include "imaging/IPixelariumImage.hpp"
#include "imgui.h"
/// @brief Checks if the dimensions of two ImVec2 vectors have changed significantly.
@@ -23,14 +24,14 @@ static bool dim_changed_p(const ImVec2& ref_rect, const ImVec2& new_rect)
/// @param img The input image.
/// @param curr_dim The current dimensions.
/// @return The calculated dimensions maintaining aspect ratio.
ImVec2 aspect_const_dimensions(const pixelarium::imaging::PixelariumImage& img, const ImVec2& curr_dim)
ImVec2 aspect_const_dimensions(const ImVec2& raw_dim, const ImVec2& curr_dim)
{
const auto w_fact = (static_cast<float>(curr_dim.x) / img.GetImage().cols);
const auto h_fact = (static_cast<float>(curr_dim.y) / img.GetImage().rows);
const auto w_fact = (curr_dim.x / raw_dim.x);
const auto h_fact = (curr_dim.y / raw_dim.y);
const auto fact = w_fact < h_fact ? w_fact : h_fact;
return ImVec2(img.GetImage().cols * fact, img.GetImage().rows * fact);
return ImVec2(raw_dim.x * fact, raw_dim.y * fact);
}
/// @brief Displays the image in an ImGui window.
@@ -40,13 +41,18 @@ ImVec2 aspect_const_dimensions(const pixelarium::imaging::PixelariumImage& img,
/// fit the available window space. The raw and rendered dimensions are displayed below the image.
void pixelarium::render::PixelariumImageView::ShowImage()
{
if (this->img_ == nullptr || this->img_->Empty() || this->img_->Name().empty())
if (!this->cached_image_.has_value())
{
this->cached_image_ = this->img_->TryGetImage();
}
if (this->img_->Empty() || this->img_->type_ == imaging::ImageFileType::UNKNOWN || !cached_image_.has_value() || this->img_->Name().empty())
{
// do nothing
return;
}
ImGui::Begin(img_->Name().c_str(), &this->open_p, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_MenuBar);
ImGui::Begin(this->img_->Name().c_str(), &this->open_p, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_MenuBar);
this->curr_dim_ = ImGui::GetContentRegionAvail();
auto new_dim = ImGui::GetContentRegionAvail();
@@ -57,10 +63,10 @@ void pixelarium::render::PixelariumImageView::ShowImage()
this->curr_dim_ = new_dim;
ImVec2 dim(this->img_->GetImage().cols, this->img_->GetImage().rows);
ImVec2 dim(cached_image_.value()->cols, cached_image_.value()->rows);
ImGui::Image(reinterpret_cast<ImTextureID>(reinterpret_cast<void*>(texture)),
aspect_const_dimensions(*this->img_, new_dim));
aspect_const_dimensions(dim, new_dim));
ImGui::Separator();
ImGui::Text("%s", std::format(" Raw Dimensions W : {}, H: {}", dim.x, dim.y).c_str());