Files
pixelarium/lib/imaging/PixelariumImageFactory.cpp
T
m-aXimilian b37814204f Misc (#19)
* get image returns optional<Mat> instead of unique_ptr<Mat>

* introduce complexity

* rename image load function

* add example for a basic reader for binary image files

* fix windows build?

* add a status bar underneath the menu bar

* use status bar in custom_0 example app

* clang formats

* packing w/ pragma push

* add "Save As" functions to image views

* resize over reserve

* rm local override uri

* add simple thread pool

* rename to simple_thread_pool

* get rid of useless renderlib

* document version inc

* extract hardcoded values to in-header

* clang format patch

* clone registered image in custom_0

* document binary-file header

* minor fixes

* clang format

* rm unused render cmake
2026-02-16 20:36:48 +01:00

39 lines
1.2 KiB
C++

#include "PixelariumImageFactory.hpp"
#include <cctype>
#include <memory>
#include "imaging/IPixelariumImage.hpp"
#include "imaging/impl/PixelariumMem.hpp"
#include "impl/PixelariumCzi.hpp"
#include "impl/PixelariumJpg.hpp"
#include "impl/PixelariumPng.hpp"
#include "impl/PixelariumTiff.hpp"
/*static*/ std::unique_ptr<pixelarium::imaging::IPixelariumImageCvMat>
pixelarium::imaging::PixelariumImageFactory::CreateImage(const std::string& uri, const Log& log)
{
const auto res{std::filesystem::path(uri)};
const auto target_type{ExtensionToType(res.extension().string())};
switch (target_type)
{
case ImageFileType::kUnknown:
return {};
case ImageFileType::kAbstract:
return {};
case ImageFileType::kPng:
return std::make_unique<PixelariumPng>(uri);
case ImageFileType::kJpg:
return std::make_unique<PixelariumJpg>(uri);
case ImageFileType::kCzi:
return std::make_unique<PixelariumCzi>(uri, log);
case ImageFileType::kTiff:
return std::make_unique<PixelariumTiff>(uri, log);
case ImageFileType::kMemory:
return std::make_unique<PixelariumMem>(cv::Mat(), uri, log);
default:
return {};
}
}