14using cimg_library::CImg;
15using cimg_library::CImgException;
17ChainableResult<std::unique_ptr<Image<Rgba32>>, ImageLoadError>
26 CImg<std::uint8_t> cimg_png{};
27 const auto path_c_str = path.c_str();
29 cimg_png.assign(path_c_str);
31 catch (
const CImgException &e) {
35 if (cimg_png.spectrum() != 3 && cimg_png.spectrum() != 4) {
39 const auto width =
static_cast<std::size_t
>(cimg_png.width());
40 const auto height =
static_cast<std::size_t
>(cimg_png.height());
44 for (std::size_t row = 0; row < height; ++row) {
45 for (std::size_t col = 0; col < width; ++col) {
46 const auto red = cimg_png(col, row, 0, 0);
47 const auto green = cimg_png(col, row, 0, 1);
48 const auto blue = cimg_png(col, row, 0, 2);
57 return std::make_unique<Image<Rgba32>>(std::move(image));
@ unsupported_channel_count
A template for two-dimensional images with arbitrarily typed pixel values.
ChainableResult< std::unique_ptr< Image< Rgba32 > >, ImageLoadError > load_from_file(const std::filesystem::path &path) const
Represents a 32-bit RGBA color.
static constexpr std::uint8_t alpha_opaque