Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::ImageLibrary Class Reference

Manages the ImageSerializer repository and the named images. More...

#include <geogram/image/image_library.h>

Inheritance diagram for GEO::ImageLibrary:
GEO::Environment GEO::Counted

Public Member Functions

bool bind_image_serializer (const std::string &extension, ImageSerializer *serializer)
 Binds an ImageSerializer. More...
 
ImageSerializerresolve_image_serializer (const std::string &extension) const
 Finds an ImageSerializer by extension. More...
 
bool bind_image (const std::string &name, Image *image)
 Binds an image with a name. More...
 
bool unbind_image (const std::string &name)
 Unbinds a named image. More...
 
Imageresolve_image (const std::string &name) const
 Finds an image by name. More...
 
Imageload_image (const std::string &file_name)
 Loads an image from a file. More...
 
bool save_image (const std::string &file_name, Image *image)
 Saves an image into a file. More...
 
void copy_image_to_clipboard (Image *image)
 Copies an image to the clipboard of the operating system. More...
 
bool get_local_value (const std::string &name, std::string &value) const override
 Retrieves a variable value locally. More...
 
bool set_local_value (const std::string &name, const std::string &value) override
 Sets a variable value locally. More...
 
- Public Member Functions inherited from GEO::Environment
virtual bool add_environment (Environment *env)
 Adds a child environment. More...
 
bool has_value (const std::string &name) const
 Tests if a variable exists. More...
 
virtual bool get_value (const std::string &name, std::string &value) const
 Retrieves the value of a variable. More...
 
std::string get_value (const std::string &name) const
 Retrieves the value of a variable. More...
 
virtual bool set_value (const std::string &name, const std::string &value)
 Sets a variable value. More...
 
virtual Environmentfind_environment (const std::string &name)
 Finds the environment that declares a variable as a local name. More...
 
virtual bool add_observer (const std::string &name, VariableObserver *observer)
 Attaches an observer to a variable. More...
 
virtual bool remove_observer (const std::string &name, VariableObserver *observer)
 Detaches an observer from a variable. More...
 
virtual bool notify_observers (const std::string &name, bool recursive=false)
 Notifies observers. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Static Public Member Functions

static ImageLibraryinstance ()
 Gets the instance. More...
 
static void initialize ()
 Initializes the ImageLibrary instance. More...
 
static void terminate ()
 Terminates the ImageLibrary instance. More...
 
- Static Public Member Functions inherited from GEO::Environment
static Environmentinstance ()
 Gets the root environment. More...
 
static void terminate ()
 Cleans up the environment. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Friends

class World
 

Additional Inherited Members

- Protected Member Functions inherited from GEO::Environment
 ~Environment () override
 Environment destructor. More...
 
bool notify_observers (const std::string &name, const std::string &value, bool recursive)
 Notifies observers. More...
 
bool notify_local_observers (const std::string &name, const std::string &value)
 Notifies local observers. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Detailed Description

Manages the ImageSerializer repository and the named images.

Definition at line 68 of file image_library.h.

Member Function Documentation

◆ bind_image()

bool GEO::ImageLibrary::bind_image ( const std::string &  name,
Image image 
)

Binds an image with a name.

Parameters
[in]namethe name of the image
[in]imagea pointer to the image to be bound. Ownership is transferred to this ImageLibrary.
Return values
trueif the Image could be successfully bound
falseotherwise, i.e. if there was already an Image bound with the same name

◆ bind_image_serializer()

bool GEO::ImageLibrary::bind_image_serializer ( const std::string &  extension,
ImageSerializer serializer 
)

Binds an ImageSerializer.

Parameters
[in]extensionthe file extension without the "."
[in]serializera pointer to an ImageSerializer. Ownership is transferred to this ImageLibrary
Return values
trueif the ImageSerializer could be successfully bound
falseotherwise (i.e. if there was already a serializer with the same name).

◆ copy_image_to_clipboard()

void GEO::ImageLibrary::copy_image_to_clipboard ( Image image)

Copies an image to the clipboard of the operating system.

Parameters
[in]imagethe image to be copied to the clipboard.
Note
Only implemented under Windows

◆ get_local_value()

bool GEO::ImageLibrary::get_local_value ( const std::string &  name,
std::string &  value 
) const
overridevirtual

Retrieves a variable value locally.

This function is used internally. It searches variable name locally and stores its value in the output string value.

Parameters
[in]namethe name of the variable
[out]valueis set the variable value if it was found locally.
Return values
trueif the variable was found
falseif not
Note
This function must be reimplemented in derived custom environments.

Provides the following environment variables:

  • image_read_extensions
  • image_write_extensions

Implements GEO::Environment.

◆ initialize()

static void GEO::ImageLibrary::initialize ( )
static

Initializes the ImageLibrary instance.

This function is automatically called during Geogram startup. It should not be called by client code.

◆ instance()

static ImageLibrary* GEO::ImageLibrary::instance ( )
static

Gets the instance.

Returns
a pointer to the unique instance of ImageLibrary.

◆ load_image()

Image* GEO::ImageLibrary::load_image ( const std::string &  file_name)

Loads an image from a file.

Parameters
[in]file_namethe name of the file that contains the image
Returns
a pointer to the loaded image, or nil if the image could not be loaded.
Note
The returned pointer can be stored in an Image_var

◆ resolve_image()

Image* GEO::ImageLibrary::resolve_image ( const std::string &  name) const

Finds an image by name.

Parameters
[in]namethe name of the image
Returns
a pointer to the image, or nil if no image is bound to the name
See also
bind_image(), unbind_image()

◆ resolve_image_serializer()

ImageSerializer* GEO::ImageLibrary::resolve_image_serializer ( const std::string &  extension) const

Finds an ImageSerializer by extension.

Parameters
[in]extensionthe file extension without the "."
Returns
a pointer to the ImageSerializer that can serialize images in the file format that corresponds to the extension, or nil if no such ImageSerializer was found

◆ save_image()

bool GEO::ImageLibrary::save_image ( const std::string &  file_name,
Image image 
)

Saves an image into a file.

Parameters
[in]file_namethe name of the file that will receive the image
[in]imagea pointer to the Image to be saved
Return values
trueif the image could be successfully saved
falseotherwise

◆ set_local_value()

bool GEO::ImageLibrary::set_local_value ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Sets a variable value locally.

This function is used internally. It sets the variable named name to the given value locally.

Parameters
[in]namethe name of the variable
[in]valuethe value of the variable
Return values
trueif the variable was successfully added locally
falseotherwise
Note
This function must be reimplemented in derived custom environments.

Implements GEO::Environment.

◆ terminate()

static void GEO::ImageLibrary::terminate ( )
static

Terminates the ImageLibrary instance.

This function is automatically called during Geogram shutdown. It should not be called by client code.

◆ unbind_image()

bool GEO::ImageLibrary::unbind_image ( const std::string &  name)

Unbinds a named image.

Parameters
[in]namethe name of the image
Return values
trueif the Image could be successfully unbound
falseotherwise, i.e. if there was no Image bound with the specified name

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