23#ifndef VCL_IO_IMAGE_SAVE_H
24#define VCL_IO_IMAGE_SAVE_H
36#include <vclib/space/core.h>
50inline std::set<FileFormat> saveImageFormats()
52 std::set<FileFormat> ff;
55 auto fqt = qt::saveImageFormats();
56 ff.insert(fqt.begin(), fqt.end());
60 auto fstb = stb::saveImageFormats();
61 ff.insert(fstb.begin(), fstb.end());
66inline void saveImageData(
67 const std::string& filename,
70 const unsigned char* data,
76 if (qt::saveImageFormats().contains(ff)) {
77 return qt::saveImageData(filename, w, h, data, quality);
81#ifdef VCLIB_WITH_TINYGLTF
82 if (stb::saveImageFormats().contains(ff)) {
83 return stb::saveImageData(filename, w, h, data, quality);
86 if (ff == FileFormat(
"bmp")) {
88 return saveImageToBmp(filename, w, h, data);
90 throw UnknownFileFormatException(ff.extensions().front());
93inline void saveImage(
const Image& image,
const std::string& filename)
95 saveImageData(filename, image.width(), image.height(), image.data());
static FileFormat fileFormat(const std::string &filename)
Get the file format of a file from its filename.
Definition file_info.h:280