Files
pixelarium/lib/rendering/ImageViewFactory.cpp
T
m-aXimilian 1ea83d9d11 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.
2026-02-16 20:36:48 +01:00

52 lines
1.7 KiB
C++

#include "ImageViewFactory.hpp"
#include <format>
#include <memory>
#include "imaging/PixelariumImageFactory.hpp"
#include "rendering/IPixelariumImageView.hpp"
#include "rendering/PixelariumImageViewCzi.hpp"
#include "rendering/PixelariumImageViewDefault.hpp"
/// @brief Creates a PixelariumImageView from a resource image.
/// @param image_id The ID of the image resource to render.
/// @return A unique pointer to the PixelariumImageView, or nullptr if the image resource is not found or is empty. The
/// image data is copied.
std::unique_ptr<pixelarium::render::IPixelariumImageView> pixelarium::render::ImageViewFactory::RenderImage(
resources::ResourceKey image_id)
{
auto res{this->image_pool_.GetResource(image_id)};
auto img{res.lock()};
if (img == nullptr)
{
return {};
}
if (img->Empty())
{
return {};
}
auto type = imaging::ExtensionToType(img->Uri().extension().string());
switch (type)
{
case imaging::ImageFileType::UNKNOWN:
case imaging::ImageFileType::ABSTRACT:
return {};
case imaging::ImageFileType::PNG:
case imaging::ImageFileType::JPG:
log_.Info(std::format("{}: Creating a Default View", __PRETTY_FUNCTION__));
// beware: here we copy the actual image resource over to the new image
return std::make_unique<PixelariumImageViewDefault>(img);
case imaging::ImageFileType::CZI:
log_.Info(std::format("{}: Creating a CZI View", __PRETTY_FUNCTION__));
// beware: here we copy the actual image resource over to the new image
return std::make_unique<PixelariumImageViewCzi>(img, log_);
default:
return {};
}
}