cgv
|
the image reader chooses a specific reader automatically based on the extension of the given file name. More...
#include <image_reader.h>
Public Member Functions | |
image_reader (cgv::data::data_format &file_format, std::vector< cgv::data::data_format > *palette_formats=0) | |
construct an image reader from a reference to a data format instance in which the format of the image file will be stored after a call to the open method. | |
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 | |
const std::string & | get_last_error () const |
return a reference to the last error message | |
bool | read_image (const std::string &file_name, cgv::data::data_view &dv, std::vector< cgv::data::data_view > *palettes=0) |
read the whole image into the given data view. | |
bool | read_image (const std::string &file_name, const cgv::data::data_view &dv, const std::vector< cgv::data::data_view > *palettes=0) |
read the image into the given data view that must have the correct format and an allocated data pointer. | |
bool | open (const std::string &file_name) |
open the file and read the image header in order to determine the data format of the file, which is stored in the data format specified in the constructor | |
cgv::data::data_format * | get_file_format () const |
return the data format of the image file | |
bool | supports_multiple_images () const |
whether the file can contain several images | |
unsigned | get_nr_images () const |
return the number of images in the file, what can cause the whole file to be scanned | |
float | get_image_duration () const |
return the duration of the current image in seconds, if returned value is 0, no duration is available | |
unsigned | get_current_image () const |
return the index of the current image | |
bool | seek_image (unsigned idx) |
jump to a specific image and return whether this was successful | |
bool | read_palette (unsigned int i, cgv::data::data_view &dv) |
read the i-th palette in case of a paletted file format, and handle the data view as in the read_image method the standard implementation returns false | |
bool | read_palette (unsigned int i, const cgv::data::data_view &dv) |
read the i-th palette in case of a paletted file format, and handle the data view as in the read_image method the standard implementation returns false | |
bool | supports_per_line_read () const |
return whether the reader supports per line reading (only valid after successfully opening an image file) | |
bool | read_line (cgv::data::data_view &dv) |
read the next line into the given data view. | |
bool | read_line (const cgv::data::data_view &dv) |
read line into a preallocated data view of the correct format | |
bool | read_image (cgv::data::data_view &dv, std::vector< cgv::data::data_view > *palettes=0) |
read an opened image data and palettes into a data views that are optionally allocated. | |
bool | read_image (const cgv::data::data_view &dv, const std::vector< cgv::data::data_view > *palettes=0) |
read image to a data_view with the correct format and an allocated pointer | |
bool | close () |
close the image file | |
![]() | |
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, true > | get_named () |
perform downcast to named | |
virtual data::ref_ptr< node, true > | get_node () |
perform downcast to node | |
virtual data::ref_ptr< group, true > | get_group () |
perform downcast to group | |
virtual data::ref_ptr< const named, true > | get_named_const () const |
perform downcast to const named | |
virtual data::ref_ptr< const node, true > | get_node_const () const |
perform downcast to const node | |
virtual data::ref_ptr< const group, true > | get_group_const () const |
perform downcast to const group | |
template<class T > | |
data::ref_ptr< T, true > | cast () |
cast to arbitrary class, but use the casts to named, node and group from the interface | |
template<class T > | |
data::ref_ptr< const T, true > | cast_const () |
const cast to arbitrary class, but use the casts to named, node and group from the interface | |
template<class T > | |
T * | get_interface () |
use dynamic type cast to check for the given interface | |
template<class T > | |
const T * | get_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 void * | get_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 > ¶m_value_types, const std::vector< const void * > ¶m_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. | |
void * | find_member_ptr (const std::string &property_name, std::string *type_name=0) |
find a member pointer by name. | |
![]() | |
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 | |
![]() | |
virtual | ~base () |
make destructor virtual and not accessible from outside | |
![]() | |
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 | |
cgv::data::data_format * | file_format_ptr |
store the data format | |
std::vector< cgv::data::data_format > * | palette_formats |
store a pointer to the palette format vector | |
abst_image_reader * | rd |
store a pointer to the chosen reader | |
std::string | last_error |
last error message in case no reader is available | |
Additional Inherited Members | |
![]() | |
template<class T > | |
static data::ref_ptr< T, true > | cast_dynamic (base *b) |
use dynamic cast for upcast to given class | |
the image reader chooses a specific reader automatically based on the extension of the given file name.
In the open method it sets the format passed by reference to the reader in the constructor.
Definition at line 61 of file image_reader.h.
cgv::media::image::image_reader::image_reader | ( | cgv::data::data_format & | file_format, |
std::vector< cgv::data::data_format > * | palette_formats = 0 |
||
) |
construct an image reader from a reference to a data format instance in which the format of the image file will be stored after a call to the open method.
construct an image image_reader from a file name
If also images with palettes should be handled, provide also a vector of data formats for the palettes. By default no vector is provided such that the reader converts paletted image formats to non paletted ones. In case palettes are used, the components in the file_format will be '0', '1', ... for the components that reference the i-th palette.
Definition at line 79 of file image_reader.cxx.
|
inline |
Definition at line 83 of file image_reader.h.
bool cgv::media::image::image_reader::close | ( | ) |
close the image file
Definition at line 296 of file image_reader.cxx.
References cgv::media::image::abst_image_reader::close(), and rd.
Referenced by cgv::render::build_render_info(), read_image(), and read_image().
|
static |
use this to generate a file_open_dialog or file_save_dialog
Definition at line 101 of file image_reader.cxx.
References get_supported_extensions(), and cgv::utils::replace().
unsigned cgv::media::image::image_reader::get_current_image | ( | ) | const |
return the index of the current image
Definition at line 196 of file image_reader.cxx.
References cgv::media::image::abst_image_reader::get_current_image(), and rd.
data_format * cgv::media::image::image_reader::get_file_format | ( | ) | const |
return the data format of the image file
return the image info
Definition at line 168 of file image_reader.cxx.
References file_format_ptr.
float cgv::media::image::image_reader::get_image_duration | ( | ) | const |
return the duration of the current image in seconds, if returned value is 0, no duration is available
return the duration of the current image in seconds
Definition at line 188 of file image_reader.cxx.
References cgv::media::image::abst_image_reader::get_image_duration(), and rd.
Referenced by cgv::render::gl::read_image_to_textures().
const std::string & cgv::media::image::image_reader::get_last_error | ( | ) | const |
return a reference to the last error message
Definition at line 113 of file image_reader.cxx.
References cgv::media::image::abst_image_reader::get_last_error(), last_error, and rd.
Referenced by cgv::render::texture::create_from_image(), cgv::render::gl::read_image_to_texture(), and cgv::render::gl::read_image_to_textures().
unsigned cgv::media::image::image_reader::get_nr_images | ( | ) | const |
return the number of images in the file, what can cause the whole file to be scanned
Definition at line 180 of file image_reader.cxx.
References cgv::media::image::abst_image_reader::get_nr_images(), and rd.
Referenced by cgv::render::gl::read_image_to_textures().
|
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 311 of file image_reader.cxx.
References cgv::base::base::get_property_declarations(), and rd.
|
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 85 of file image_reader.cxx.
References get_supported_extensions(), and cgv::utils::replace().
Referenced by construct_filter_string(), get_supported_extensions(), and open().
|
virtual |
overload to return the type name of this object
Reimplemented from cgv::base::base.
Definition at line 304 of file image_reader.cxx.
References cgv::base::base::get_type_name(), and rd.
|
protectedvirtual |
abstract interface for the getter, by default it simply returns false
Reimplemented from cgv::base::base.
Definition at line 326 of file image_reader.cxx.
References cgv::base::base::get_void(), and rd.
open the file and read the image header in order to determine the data format of the file, which is stored in the data format specified in the constructor
open the file and read the image header in order to determine the data format
Definition at line 141 of file image_reader.cxx.
References file_format_ptr, get_supported_extensions(), cgv::utils::is_element(), last_error, cgv::media::image::abst_image_reader::open(), palette_formats, rd, and cgv::utils::to_lower().
Referenced by cgv::render::build_render_info(), read_image(), read_image(), and cgv::render::gl::read_image_to_textures().
bool cgv::media::image::image_reader::read_image | ( | cgv::data::data_view & | dv, |
std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
read an opened image data and palettes into a data views that are optionally allocated.
read the whole image into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done. If image file has not been opened yet, open it and close it after reading
read an image from an opened image file into the given data view. If the data format of the view has not been specified, set it to the data format of the file. If the data pointer is empty, allocate enough memory to hold the image. The pointer is then owned by the view.
Definition at line 259 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), file_format_ptr, palette_formats, rd, cgv::media::image::abst_image_reader::read_image(), and read_palette().
bool cgv::media::image::image_reader::read_image | ( | const cgv::data::data_view & | dv, |
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
read image to a data_view with the correct format and an allocated pointer
read the whole image into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done. If image file has not been opened yet, open it and close it after reading
Definition at line 277 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), file_format_ptr, palette_formats, rd, cgv::media::image::abst_image_reader::read_image(), and read_palette().
bool cgv::media::image::image_reader::read_image | ( | const std::string & | file_name, |
cgv::data::data_view & | dv, | ||
std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
read the whole image into the given data view.
read the whole image into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done. If image file has not been opened yet, open it and close it after reading
If the data view is empty, set the format and allocate memory to hold the image data. The newly allocate data pointer will belong to the data view afterwards. If the data pointer of the data view is already allocated, use this in the same way as the alternate version of read_image with the const data_view argument does.
Definition at line 121 of file image_reader.cxx.
References close(), cgv::data::component_format::empty(), file_format_ptr, open(), and read_image().
Referenced by cgv::render::build_render_info(), cgv::render::texture::create_from_image(), read_image(), read_image(), cgv::render::gl::read_image_to_texture(), cgv::render::gl::read_image_to_textures(), and cgv::render::texture::replace_from_image().
bool cgv::media::image::image_reader::read_image | ( | const std::string & | file_name, |
const cgv::data::data_view & | dv, | ||
const std::vector< cgv::data::data_view > * | palettes = 0 |
||
) |
read the image into the given data view that must have the correct format and an allocated data pointer.
read the whole image into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done. If image file has not been opened yet, open it and close it after reading
Definition at line 131 of file image_reader.cxx.
References close(), cgv::data::component_format::empty(), cgv::data::data_view_impl< D, P >::empty(), file_format_ptr, open(), and read_image().
bool cgv::media::image::image_reader::read_line | ( | cgv::data::data_view & | dv | ) |
read the next line into the given data view.
read the next line into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done
If the data format of the view has not been specified, set it to the data format of the file, construct a 1d subview and allocate memory for a line only. The data pointer is then owned by the view.
Definition at line 238 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), file_format_ptr, cgv::data::component_format::get_entry_size(), cgv::data::data_format::get_width(), rd, cgv::media::image::abst_image_reader::read_line(), and cgv::data::data_view::set_ptr().
bool cgv::media::image::image_reader::read_line | ( | const cgv::data::data_view & | dv | ) |
read line into a preallocated data view of the correct format
read the next line into the given data pointer, set data format if not yet specified and allocate the data ptr if not yet done
Definition at line 251 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), file_format_ptr, rd, and cgv::media::image::abst_image_reader::read_line().
bool cgv::media::image::image_reader::read_palette | ( | unsigned int | i, |
cgv::data::data_view & | dv | ||
) |
read the i-th palette in case of a paletted file format, and handle the data view as in the read_image method the standard implementation returns false
read the i-th palette in case of a paletted file format, the standard implementation returns false
In case of files with animated images, the palette can change for each image. Therefore call this method before each call to read_image()
.
Definition at line 212 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), palette_formats, rd, and cgv::media::image::abst_image_reader::read_palette().
Referenced by cgv::render::texture::create_from_image(), read_image(), read_image(), cgv::render::gl::read_image_to_textures(), and cgv::render::texture::replace_from_image().
bool cgv::media::image::image_reader::read_palette | ( | unsigned int | i, |
const cgv::data::data_view & | dv | ||
) |
read the i-th palette in case of a paletted file format, and handle the data view as in the read_image method the standard implementation returns false
read the i-th palette in case of a paletted file format, the standard implementation returns false
In case of files with animated images, the palette can change for each image. Therefore call this method before each call to read_image()
.
Definition at line 222 of file image_reader.cxx.
References cgv::data::data_view_impl< D, P >::empty(), palette_formats, rd, and cgv::media::image::abst_image_reader::read_palette().
jump to a specific image and return whether this was successful
Definition at line 204 of file image_reader.cxx.
References rd, and cgv::media::image::abst_image_reader::seek_image().
|
protectedvirtual |
abstract interface for the setter, by default it simply returns false
Reimplemented from cgv::base::base.
Definition at line 319 of file image_reader.cxx.
References rd, and cgv::base::base::set_void().
bool cgv::media::image::image_reader::supports_multiple_images | ( | ) | const |
whether the file can contain several images
Definition at line 174 of file image_reader.cxx.
bool cgv::media::image::image_reader::supports_per_line_read | ( | ) | const |
return whether the reader supports per line reading (only valid after successfully opening an image file)
whether the image_reader supports per line reading (only valid after successful opening an image file
Definition at line 230 of file image_reader.cxx.
References rd, and cgv::media::image::abst_image_reader::supports_per_line_read().
|
protected |
store the data format
Definition at line 65 of file image_reader.h.
Referenced by get_file_format(), open(), read_image(), read_image(), read_image(), read_image(), read_line(), and read_line().
|
protected |
last error message in case no reader is available
Definition at line 71 of file image_reader.h.
Referenced by get_last_error(), and open().
|
protected |
store a pointer to the palette format vector
Definition at line 67 of file image_reader.h.
Referenced by open(), read_image(), read_image(), read_palette(), and read_palette().
|
protected |
store a pointer to the chosen reader
Definition at line 69 of file image_reader.h.
Referenced by close(), get_current_image(), get_image_duration(), get_last_error(), get_nr_images(), get_property_declarations(), get_type_name(), get_void(), open(), read_image(), read_image(), read_line(), read_line(), read_palette(), read_palette(), seek_image(), set_void(), and supports_per_line_read().