cgv
Loading...
Searching...
No Matches
cgv::media::image::image_writer Class Reference

the image writer chooses a specific writer automatically based on the extension of the given file name More...

#include <image_writer.h>

Inheritance diagram for cgv::media::image::image_writer:
cgv::base::base cgv::data::ref_counted cgv::reflect::self_reflection_tag

Public Member Functions

 image_writer (const std::string &file_name)
 construct an image writer from a file name and choose a writer from the extension
 
 ~image_writer ()
 close file on destruction
 
std::string get_type_name () const
 overload to return the type name of this object
 
std::string get_property_declarations ()
 return a semicolon separated list of property declarations of the form "name:type", by default an empty list is returned
 
bool is_format_supported (const cgv::data::component_format &cf, const std::vector< cgv::data::component_format > *palette_formats=0) const
 check if the chosen writer supports the given component format
 
std::string get_options () const
 return a colon separated list of supported options
 
const std::string & get_last_error () const
 return a reference to the last error message
 
bool write_image (const cgv::data::const_data_view &dv, const std::vector< cgv::data::const_data_view > *palettes=0, double duration=0)
 write the data stored in the data view to a file with the file name given in the constructor.
 
bool close ()
 close image file;
 
bool supports_multiple_images () const
 return whether multiple images are supported, default implementation returns false
 
- Public Member Functions inherited from cgv::base::base
virtual std::string get_default_options () const
 overload to provide default options for registration
 
std::string get_name_or_type_name () const
 determine name of instance by checking cgv::base::named interface and in failure fallback to get_type_name()
 
virtual void on_register ()
 overload to handle register events that is sent after the instance has been registered
 
virtual void unregister ()
 overload to handle unregistration of instances
 
virtual bool on_exit_request ()
 overload to handle the appication exit request, return true if exiting is allowed and false otherwise
 
virtual void stream_stats (std::ostream &)
 overload to show the content of this object
 
virtual data::ref_ptr< named, trueget_named ()
 perform downcast to named
 
virtual data::ref_ptr< node, trueget_node ()
 perform downcast to node
 
virtual data::ref_ptr< group, trueget_group ()
 perform downcast to group
 
virtual data::ref_ptr< const named, trueget_named_const () const
 perform downcast to const named
 
virtual data::ref_ptr< const node, trueget_node_const () const
 perform downcast to const node
 
virtual data::ref_ptr< const group, trueget_group_const () const
 perform downcast to const group
 
template<class T >
data::ref_ptr< T, truecast ()
 cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
data::ref_ptr< const T, truecast_const ()
 const cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
Tget_interface ()
 use dynamic type cast to check for the given interface
 
template<class T >
const Tget_const_interface () const
 use dynamic type cast to check for the given interface
 
virtual void update ()
 this virtual update allows for example to ask a view to update the viewed value. The default implementation is empty.
 
virtual voidget_user_data () const
 this virtual method allows to pass application specific data for internal purposes
 
virtual bool self_reflect (cgv::reflect::reflection_handler &)
 used for simple self reflection
 
virtual void on_set (void *member_ptr)
 this callback is called when the set_void method has changed a member and can be overloaded in derived class
 
virtual bool call_void (const std::string &method, const std::vector< std::string > &param_value_types, const std::vector< const void * > &param_value_ptrs, const std::string &result_type="", void *result_value_ptr=0)
 abstract interface to call an action
 
void set (const std::string &property, const char *value)
 specialization of set method to support const char* as strings
 
template<typename T >
void set (const std::string &property, const T &value)
 set a property of the element to the given value and perform standard conversions if necessary.
 
template<typename T >
T get (const std::string &property)
 query a property of the element and perform standard conversions if necessary.
 
void multi_set (const std::string &property_assignments, bool report_error=true)
 set several properties
 
bool is_property (const std::string &property_name, std::string *type_name=0)
 check if the given name specifies a property.
 
voidfind_member_ptr (const std::string &property_name, std::string *type_name=0)
 find a member pointer by name.
 
- Public Member Functions inherited from cgv::data::ref_counted
int get_ref_count () const
 read access to current count
 

Static Public Member Functions

static const std::string & get_supported_extensions (char sep=';')
 return a string with a list of supported extensions, where the list entries are separated with the passed character that defaults to a semicolon
 
static std::string construct_filter_string ()
 use this to generate a file_open_dialog or file_save_dialog
 

Protected Member Functions

bool set_void (const std::string &property, const std::string &type, const void *value)
 abstract interface for the setter, by default it simply returns false
 
bool get_void (const std::string &property, const std::string &type, void *value)
 abstract interface for the getter, by default it simply returns false
 
- Protected Member Functions inherited from cgv::base::base
virtual ~base ()
 make destructor virtual and not accessible from outside
 
- Protected Member Functions inherited from cgv::data::ref_counted
 ref_counted ()
 constructor initializes the count to 0
 
void set_ref_count (int c) const
 write access is also const to allow ref counted pointers to const instances
 

Protected Attributes

abst_image_writerwr
 store a pointer to the chosen reader
 
bool is_opened
 whether file has been opened
 
std::string file_name
 store the file name
 
std::string last_error
 store the last error not resulting from writer implementations
 

Additional Inherited Members

- Static Protected Member Functions inherited from cgv::base::base
template<class T >
static data::ref_ptr< T, truecast_dynamic (base *b)
 use dynamic cast for upcast to given class
 

Detailed Description

the image writer chooses a specific writer automatically based on the extension of the given file name

Definition at line 39 of file image_writer.h.

Constructor & Destructor Documentation

◆ image_writer()

cgv::media::image::image_writer::image_writer ( const std::string &  file_name)

construct an image writer from a file name and choose a writer from the extension

construct an image image_writer from a file name and choose a image_writer from the extension

Definition at line 49 of file image_writer.cxx.

References file_name, cgv::utils::is_element(), is_opened, last_error, cgv::utils::to_lower(), and wr.

◆ ~image_writer()

cgv::media::image::image_writer::~image_writer ( )

close file on destruction

Definition at line 116 of file image_writer.cxx.

References close().

Member Function Documentation

◆ close()

bool cgv::media::image::image_writer::close ( )

◆ construct_filter_string()

std::string cgv::media::image::image_writer::construct_filter_string ( )
static

use this to generate a file_open_dialog or file_save_dialog

Definition at line 88 of file image_writer.cxx.

References get_supported_extensions(), and cgv::utils::replace().

◆ get_last_error()

const std::string & cgv::media::image::image_writer::get_last_error ( ) const

return a reference to the last error message

Definition at line 108 of file image_writer.cxx.

References cgv::media::image::abst_image_writer::get_last_error(), last_error, and wr.

◆ get_property_declarations()

std::string cgv::media::image::image_writer::get_property_declarations ( )
virtual

return a semicolon separated list of property declarations of the form "name:type", by default an empty list is returned

Reimplemented from cgv::base::base.

Definition at line 162 of file image_writer.cxx.

References cgv::base::base::get_property_declarations(), and wr.

◆ get_supported_extensions()

const std::string & cgv::media::image::image_writer::get_supported_extensions ( char  sep = ';')
static

return a string with a list of supported extensions, where the list entries are separated with the passed character that defaults to a semicolon

Definition at line 72 of file image_writer.cxx.

References get_supported_extensions(), and cgv::utils::replace().

Referenced by construct_filter_string(), and get_supported_extensions().

◆ get_type_name()

std::string cgv::media::image::image_writer::get_type_name ( ) const
virtual

overload to return the type name of this object

Reimplemented from cgv::base::base.

Definition at line 155 of file image_writer.cxx.

References cgv::base::base::get_type_name(), and wr.

◆ get_void()

bool cgv::media::image::image_writer::get_void ( const std::string &  property,
const std::string &  type,
void value 
)
protectedvirtual

abstract interface for the getter, by default it simply returns false

Reimplemented from cgv::base::base.

Definition at line 177 of file image_writer.cxx.

References cgv::base::base::get_void(), and wr.

◆ is_format_supported()

bool cgv::media::image::image_writer::is_format_supported ( const cgv::data::component_format cf,
const std::vector< cgv::data::component_format > *  palette_formats = 0 
) const

check if the chosen writer supports the given component format

check if the chosen image_writer supports the given component format

Definition at line 100 of file image_writer.cxx.

References cgv::media::image::abst_image_writer::is_format_supported(), and wr.

◆ set_void()

bool cgv::media::image::image_writer::set_void ( const std::string &  property,
const std::string &  type,
const void value 
)
protectedvirtual

abstract interface for the setter, by default it simply returns false

Reimplemented from cgv::base::base.

Definition at line 170 of file image_writer.cxx.

References cgv::base::base::set_void(), and wr.

◆ supports_multiple_images()

bool cgv::media::image::image_writer::supports_multiple_images ( ) const

return whether multiple images are supported, default implementation returns false

Definition at line 147 of file image_writer.cxx.

References cgv::media::image::abst_image_writer::supports_multiple_images(), and wr.

◆ write_image()

bool cgv::media::image::image_writer::write_image ( const cgv::data::const_data_view dv,
const std::vector< cgv::data::const_data_view > *  palettes = 0,
double  duration = 0 
)

write the data stored in the data view to a file with the file name given in the constructor.

In case a vector of data views for palettes is given, write the image in paletted format.

Definition at line 132 of file image_writer.cxx.

References file_name, is_opened, cgv::media::image::abst_image_writer::open(), wr, and cgv::media::image::abst_image_writer::write_image().

Referenced by cgv::render::context::write_frame_buffer_to_image(), cgv::media::volume::ooc_sliced_volume::write_slice(), and cgv::render::texture::write_to_file().

Member Data Documentation

◆ file_name

std::string cgv::media::image::image_writer::file_name
protected

store the file name

Definition at line 47 of file image_writer.h.

Referenced by image_writer(), and write_image().

◆ is_opened

bool cgv::media::image::image_writer::is_opened
protected

whether file has been opened

Definition at line 45 of file image_writer.h.

Referenced by close(), image_writer(), and write_image().

◆ last_error

std::string cgv::media::image::image_writer::last_error
protected

store the last error not resulting from writer implementations

Definition at line 49 of file image_writer.h.

Referenced by get_last_error(), and image_writer().

◆ wr

abst_image_writer* cgv::media::image::image_writer::wr
protected

The documentation for this class was generated from the following files: