Files
pixelarium/lib/imaging/PixelariumImageFactory.hpp
T

39 lines
1.0 KiB
C++
Raw Normal View History

2025-09-22 23:13:28 +02:00
#pragma once
#include <memory>
#include "IPixelariumImage.hpp"
2025-09-26 21:09:51 +02:00
#include "utilities/ILog.hpp"
2025-09-22 23:13:28 +02:00
namespace pixelarium::imaging
{
2025-09-23 21:57:08 +02:00
constexpr pixelarium::imaging::ImageFileType ExtensionToType(const std::string& extension)
{
std::string lower_ext{extension};
std::ranges::transform(extension, lower_ext.begin(), [](const char c) -> char { return std::tolower(c); });
if (lower_ext == ".jpg" || lower_ext == ".jpeg")
{
2025-10-07 12:18:00 +02:00
return pixelarium::imaging::ImageFileType::kJpg;
2025-09-23 21:57:08 +02:00
}
if (lower_ext == ".png")
{
2025-10-07 12:18:00 +02:00
return pixelarium::imaging::ImageFileType::kPng;
2025-09-23 21:57:08 +02:00
}
if (lower_ext == ".czi")
{
2025-10-07 12:18:00 +02:00
return pixelarium::imaging::ImageFileType::kCzi;
2025-09-23 21:57:08 +02:00
}
2025-10-07 12:18:00 +02:00
return pixelarium::imaging::ImageFileType::kUnknown;
2025-09-23 21:57:08 +02:00
}
2025-09-26 21:09:51 +02:00
/// @brief Factory for instantiating implementations of IPixelariumImage based on the given file type.
2025-09-22 23:13:28 +02:00
class PixelariumImageFactory
{
2025-09-26 21:09:51 +02:00
using Log = utils::log::ILog;
2025-09-22 23:13:28 +02:00
public:
2025-09-26 21:09:51 +02:00
static std::unique_ptr<IPixelariumImage> CreateImage(const std::string& uri, const Log& log);
2025-09-22 23:13:28 +02:00
};
} // namespace pixelarium::imaging