cgv
Loading...
Searching...
No Matches
image_writer.h
1#pragma once
2
3#include <cgv/base/base.h>
4#include <cgv/base/register.h>
5#include <cgv/data/data_view.h>
6
7#include "lib_begin.h"
8
9namespace cgv {
10 namespace media {
11 namespace image {
12
13class CGV_API image_writer;
14
17{
18public:
19 friend class image_writer;
21 virtual abst_image_writer* clone() const = 0;
23 virtual const char* get_supported_extensions() const = 0;
25 virtual bool is_format_supported(const cgv::data::component_format& cf, const std::vector<cgv::data::component_format>* palette_formats) const = 0;
27 virtual const std::string& get_last_error() const = 0;
29 virtual bool supports_multiple_images() const;
31 virtual bool open(const std::string& file_name) = 0;
33 virtual bool write_image(const cgv::data::const_data_view& dv, const std::vector<cgv::data::const_data_view>* palettes, double duration) = 0;
35 virtual bool close() = 0;
36};
37
39class CGV_API image_writer : public cgv::base::base
40{
41protected:
47 std::string file_name;
49 std::string last_error;
51 bool set_void(const std::string& property, const std::string& type, const void* value);
53 bool get_void(const std::string& property, const std::string& type, void* value);
54public:
56 image_writer(const std::string& file_name);
60 std::string get_type_name() const;
62 static const std::string& get_supported_extensions(char sep = ';');
64 static std::string construct_filter_string();
66 std::string get_property_declarations();
68 bool is_format_supported(const cgv::data::component_format& cf, const std::vector<cgv::data::component_format>* palette_formats = 0) const;
70 std::string get_options() const;
72 const std::string& get_last_error() const;
75 bool write_image(const cgv::data::const_data_view& dv, const std::vector<cgv::data::const_data_view>* palettes = 0, double duration = 0);
77 bool close();
79 bool supports_multiple_images() const;
80};
81
82 }
83 }
84}
85
86#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
Definition base.h:75
the component format inherits the information of a packing_info and adds information on the component...
The const_data_view has the functionality of the data_view but uses a const pointer and therefore doe...
Definition data_view.h:221
abstract interface for image readers
virtual bool close()=0
close image [stream]
virtual const std::string & get_last_error() const =0
return a reference to the last error message
virtual bool open(const std::string &file_name)=0
open image file to write
virtual const char * get_supported_extensions() const =0
return a string containing a colon separated list of extensions that can be read with this reader
virtual abst_image_writer * clone() const =0
construct a copy of the reader
virtual bool is_format_supported(const cgv::data::component_format &cf, const std::vector< cgv::data::component_format > *palette_formats) const =0
check if the chosen writer supports the given component format
virtual bool write_image(const cgv::data::const_data_view &dv, const std::vector< cgv::data::const_data_view > *palettes, double duration)=0
write one image
the image writer chooses a specific writer automatically based on the extension of the given file nam...
bool is_opened
whether file has been opened
std::string last_error
store the last error not resulting from writer implementations
std::string file_name
store the file name
abst_image_writer * wr
store a pointer to the chosen reader
std::string get_options() const
return a colon separated list of supported options
the cgv namespace
Definition print.h:11
interfaces that add several listeners and objects.
Definition register.h:210