14#include <lagrange/fs/filesystem.h>
15#include <lagrange/image/ImageView.h>
16#include <lagrange/image_io/api.h>
19#include <lagrange/utils/warnoff.h>
20#include <spdlog/common.h>
21#include <lagrange/utils/warnon.h>
32 image::ImagePrecision precision = image::ImagePrecision::unknown;
33 image::ImageChannel channel = image::ImageChannel::unknown;
34 std::shared_ptr<image::ImageStorage> storage =
nullptr;
39load_image(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
45 spdlog::level::level_enum error_lvl = spdlog::level::err);
49load_image_stb(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
54load_image_exr(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
58load_image_bin(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
65 if (!result.valid)
return false;
67 if (image::ImageTraits<T>::precision == result.precision &&
68 image::ImageTraits<T>::channel == result.channel) {
71 result.storage->get_full_size()(0) /
sizeof(T),
72 result.storage->get_full_size()(1),
79 bool valid_conversion =
false;
80#define LAGRANGE_TMP(PRECISION, CHANNEL, TYPE) \
81 if (image::ImagePrecision::PRECISION == result.precision && \
82 image::ImageChannel::CHANNEL == result.channel) { \
83 image::ImageView<TYPE> temp_image_view( \
85 result.storage->get_full_size()(0) / sizeof(TYPE), \
86 result.storage->get_full_size()(1), \
91 valid_conversion = img.convert_from(temp_image_view, 1); \
93#define LAGRANGE_TMP_COMMA ,
95 LAGRANGE_TMP(uint8, one,
unsigned char)
96 else LAGRANGE_TMP(uint8, three, Eigen::Matrix<unsigned char LAGRANGE_TMP_COMMA 3 LAGRANGE_TMP_COMMA 1>)
97 else LAGRANGE_TMP(uint8, four, Eigen::Matrix<unsigned char LAGRANGE_TMP_COMMA 4 LAGRANGE_TMP_COMMA 1>)
98 else LAGRANGE_TMP(uint16, one, uint16_t)
99 else LAGRANGE_TMP(uint16, three, Eigen::Matrix<uint16_t LAGRANGE_TMP_COMMA 3 LAGRANGE_TMP_COMMA 1>)
100 else LAGRANGE_TMP(uint16, four, Eigen::Matrix<uint16_t LAGRANGE_TMP_COMMA 4 LAGRANGE_TMP_COMMA 1>)
101 else LAGRANGE_TMP(float32, one,
float)
102 else LAGRANGE_TMP(float32, three, Eigen::Vector3f)
103 else LAGRANGE_TMP(float32, four, Eigen::Vector4f)
104 else LAGRANGE_TMP(float64, one,
double)
105 else LAGRANGE_TMP(float64, three, Eigen::Vector3d)
106 else LAGRANGE_TMP(float64, four, Eigen::Vector4d)
108 return valid_conversion;
110#undef LAGRANGE_TMP_COMMA
Definition ImageView.h:56
Main namespace for Lagrange.
Definition load_image.h:28