23#ifndef VCL_IO_IMAGE_QT_SAVE_H
24#define VCL_IO_IMAGE_QT_SAVE_H
26#include <vclib/io/file_format.h>
34inline std::set<FileFormat> saveImageFormats()
37 FileFormat(
"bmp",
"Bitmap"),
39 std::vector<std::string> {
"jpg",
"jpeg"},
40 "Joint Photographic Experts Group"),
41 FileFormat(
"png",
"Portable Network Graphics"),
42 FileFormat(
"ppm",
"Portable Pixmap"),
43 FileFormat(
"xbm",
"X11 Bitmap"),
44 FileFormat(
"xpm",
"X11 Pixmap"),
48inline void saveImageData(
49 const std::string& filename,
52 const unsigned char* data,
55 QImage image(w, h, QImage::Format_RGBA8888);
56 std::copy(data, data + w * h * 4, image.bits());
57 bool res = image.save(QString::fromStdString(filename),
nullptr, quality);
59 throw std::runtime_error(
60 "Failed to save image data to file: " + filename);