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);
43load_image_stb(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
48load_image_exr(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
52load_image_bin(
const fs::path& path, spdlog::level::level_enum error_lvl = spdlog::level::err);
59 if (!result.valid)
return false;
61 if (image::ImageTraits<T>::precision == result.precision &&
62 image::ImageTraits<T>::channel == result.channel) {
65 result.storage->get_full_size()(0) /
sizeof(T),
66 result.storage->get_full_size()(1),
73 bool valid_conversion =
false;
74#define LAGRANGE_TMP(PRECISION, CHANNEL, TYPE) \
75 if (image::ImagePrecision::PRECISION == result.precision && \
76 image::ImageChannel::CHANNEL == result.channel) { \
77 image::ImageView<TYPE> temp_image_view( \
79 result.storage->get_full_size()(0) / sizeof(TYPE), \
80 result.storage->get_full_size()(1), \
85 valid_conversion = img.convert_from(temp_image_view, 1); \
87#define LAGRANGE_TMP_COMMA ,
89 LAGRANGE_TMP(uint8, one,
unsigned char)
90 else LAGRANGE_TMP(uint8, three, Eigen::Matrix<unsigned char LAGRANGE_TMP_COMMA 3 LAGRANGE_TMP_COMMA 1>)
91 else LAGRANGE_TMP(uint8, four, Eigen::Matrix<unsigned char LAGRANGE_TMP_COMMA 4 LAGRANGE_TMP_COMMA 1>)
92 else LAGRANGE_TMP(uint16, one, uint16_t)
93 else LAGRANGE_TMP(uint16, three, Eigen::Matrix<uint16_t LAGRANGE_TMP_COMMA 3 LAGRANGE_TMP_COMMA 1>)
94 else LAGRANGE_TMP(uint16, four, Eigen::Matrix<uint16_t LAGRANGE_TMP_COMMA 4 LAGRANGE_TMP_COMMA 1>)
95 else LAGRANGE_TMP(float32, one,
float)
96 else LAGRANGE_TMP(float32, three, Eigen::Vector3f)
97 else LAGRANGE_TMP(float32, four, Eigen::Vector4f)
98 else LAGRANGE_TMP(float64, one,
double)
99 else LAGRANGE_TMP(float64, three, Eigen::Vector3d)
100 else LAGRANGE_TMP(float64, four, Eigen::Vector4d)
102 return valid_conversion;
104#undef LAGRANGE_TMP_COMMA
Definition ImageView.h:56
Main namespace for Lagrange.
Definition load_image.h:28