Porytiles
Loading...
Searching...
No Matches
png_importer_impl.cpp
Go to the documentation of this file.
2
3#include <expected>
4#include <filesystem>
5#include <memory>
6#include <string>
7
8#include <CImg.h>
9
10#include <png/impl/png_impl.hpp>
12
13namespace porytiles {
14
15using cimg_library::CImg;
16using cimg_library::CImgException;
17
18std::expected<std::unique_ptr<Png>, std::string> PngImporterImpl::Read(const std::filesystem::path &path) const {
19 CImg<std::uint8_t> image{};
20 const auto path_c_str = path.c_str();
21 try {
22 image.assign(path_c_str);
23 return std::make_unique<PngImpl>(image);
24 } catch (const CImgException &e) {
25 return std::unexpected{e.what()};
26 }
27}
28
29} // namespace porytiles
std::expected< std::unique_ptr< Png >, std::string > Read(const std::filesystem::path &path) const override
Imports a Png at a given path from the filesystem.