23#ifndef VCL_IO_IMAGE_LOAD_H
24#define VCL_IO_IMAGE_LOAD_H
34#include <vclib/io/file_format.h>
35#include <vclib/io/file_info.h>
37#include <vclib/space/core.h>
53inline std::set<FileFormat> loadImageFormats()
55 std::set<FileFormat> ff;
58 auto fqt = qt::loadImageFormats();
59 ff.insert(fqt.begin(), fqt.end());
63 auto fstb = stb::loadImageFormats();
64 ff.insert(fstb.begin(), fstb.end());
69inline std::shared_ptr<unsigned char> loadImageData(
70 const std::string& filename,
77 if (qt::loadImageFormats().contains(ff)) {
78 return qt::loadImageData(filename, w, h);
83 if (stb::loadImageFormats().contains(ff)) {
84 return stb::loadImageData(filename, w, h);
87 throw UnknownFileFormatException(ff.extensions().front());
90inline Image loadImage(
const std::string& filename)
93 auto data = loadImageData(filename, w, h);
97 return Image(data.get(), w, h);
static FileFormat fileFormat(const std::string &filename)
Get the file format of a file from its filename.
Definition file_info.h:280