cgv
image_writer.h
1 #pragma once
2 
3 #include <cgv/base/base.h>
4 #include <cgv/data/data_view.h>
5 
6 #include "lib_begin.h"
7 
8 using namespace cgv::data;
9 
10 namespace cgv {
11  namespace media {
12  namespace image {
13 
14 class CGV_API image_writer;
15 
17 class CGV_API abst_image_writer : public cgv::base::base
18 {
19 public:
20  friend class image_writer;
22  virtual abst_image_writer* clone() const = 0;
24  virtual const char* get_supported_extensions() const = 0;
26  virtual bool is_format_supported(const component_format& cf, const std::vector<component_format>* palette_formats) const = 0;
28  virtual const std::string& get_last_error() const = 0;
30  virtual bool supports_multiple_images() const;
32  virtual bool open(const std::string& file_name) = 0;
34  virtual bool write_image(const const_data_view& dv, const std::vector<const_data_view>* palettes, double duration) = 0;
36  virtual bool close() = 0;
37 };
38 
40 class CGV_API image_writer : public cgv::base::base
41 {
42 protected:
46  bool is_opened;
48  std::string file_name;
50  std::string last_error;
52  bool set_void(const std::string& property, const std::string& type, const void* value);
54  bool get_void(const std::string& property, const std::string& type, void* value);
55 public:
57  image_writer(const std::string& file_name);
59  ~image_writer();
61  std::string get_type_name() const;
63  static const std::string& get_supported_extensions(char sep = ';');
65  static std::string construct_filter_string();
67  std::string get_property_declarations();
69  bool is_format_supported(const component_format& cf, const std::vector<component_format>* palette_formats = 0) const;
71  std::string get_options() const;
73  const std::string& get_last_error() const;
76  bool write_image(const const_data_view& dv, const std::vector<const_data_view>* palettes = 0, double duration = 0);
78  bool close();
80  bool supports_multiple_images() const;
81 };
82 
83  }
84  }
85 }
86 
87 #include <cgv/config/lib_end.h>
cgv::data::component_format
Definition: component_format.h:58
cgv::media::image::abst_image_writer::clone
virtual abst_image_writer * clone() const =0
construct a copy of the reader
cgv::media::image::image_writer::wr
abst_image_writer * wr
store a pointer to the chosen reader
Definition: image_writer.h:44
cgv::media::image::image_writer::is_opened
bool is_opened
whether file has been opened
Definition: image_writer.h:46
cgv::media::image::abst_image_writer
abstract interface for image readers
Definition: image_writer.h:18
cgv::media::image::abst_image_writer::is_format_supported
virtual bool is_format_supported(const component_format &cf, const std::vector< component_format > *palette_formats) const =0
check if the chosen writer supports the given component format
cgv::media::image::abst_image_writer::open
virtual bool open(const std::string &file_name)=0
open image file to write
cgv::data::const_data_view
Definition: data_view.h:211
cgv::media::image::abst_image_writer::write_image
virtual bool write_image(const const_data_view &dv, const std::vector< const_data_view > *palettes, double duration)=0
write one image
cgv::media::image::image_writer::get_options
std::string get_options() const
return a colon separated list of supported options
cgv::media::image::abst_image_writer::get_last_error
virtual const std::string & get_last_error() const =0
return a reference to the last error message
cgv::data
namespace for data management components
Definition: ascii_io_reflection_handlers.cxx:15
cgv::media::image::image_writer
the image writer chooses a specific writer automatically based on the extension of the given file nam...
Definition: image_writer.h:41
cgv::media::image::abst_image_writer::get_supported_extensions
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
cgv::media::image::image_writer::file_name
std::string file_name
store the file name
Definition: image_writer.h:48
cgv::base::base
Definition: base.h:57
cgv::media::image::abst_image_writer::close
virtual bool close()=0
close image [stream]
cgv::type::info::get_type_name
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition: type_id.cxx:117
cgv::media::image::image_writer::last_error
std::string last_error
store the last error not resulting from writer implementations
Definition: image_writer.h:50
cgv
the cgv namespace
Definition: vr_calib.cxx:9