VAPOR3 3.9.4
ImageWriter.h
Go to the documentation of this file.
1#pragma once
2
3#include <vapor/MyBase.h>
4#include <string>
5
6namespace VAPoR {
7
8class ImageWriterFactory;
9
16public:
17 enum class Format { RGB };
18
19 // virtual static std::vector<std::string> GetFileExtensions();
20 virtual int Write(const unsigned char *buffer, const unsigned int width, const unsigned int height) = 0;
21 virtual ~ImageWriter(){};
22
23 static ImageWriter *CreateImageWriterForFile(const std::string &path);
24 static void RegisterFactory(ImageWriterFactory *factory);
25
26protected:
28 std::string path;
29 bool opened;
30
31 ImageWriter(const std::string &path);
32
33private:
34 static std::vector<ImageWriterFactory *> factories;
35};
36
38public:
39 const std::vector<std::string> Extensions;
40 virtual ImageWriter * Create(const std::string &path) = 0;
41
42protected:
43 ImageWriterFactory(std::vector<std::string> extensions) : Extensions(extensions) {}
44};
45
46#define REGISTER_IMAGEWRITER(name) \
47 class name##Factory : public ImageWriterFactory { \
48 public: \
49 name##Factory() : ImageWriterFactory(name::GetFileExtensions()) { ImageWriter::RegisterFactory(this); } \
50 virtual ImageWriter *Create(const std::string &path) { return new name(path); } \
51 }; \
52 static name##Factory registration_##name##Factory;
53
54} // namespace VAPoR
const std::vector< std::string > Extensions
Definition: ImageWriter.h:39
ImageWriterFactory(std::vector< std::string > extensions)
Definition: ImageWriter.h:43
virtual ImageWriter * Create(const std::string &path)=0
Interface for image writers.
Definition: ImageWriter.h:15
ImageWriter(const std::string &path)
static ImageWriter * CreateImageWriterForFile(const std::string &path)
virtual int Write(const unsigned char *buffer, const unsigned int width, const unsigned int height)=0
static void RegisterFactory(ImageWriterFactory *factory)
std::string path
Definition: ImageWriter.h:28
virtual ~ImageWriter()
Definition: ImageWriter.h:21
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78