AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxIO::PNGImageValueInterpreter Class Reference

#include <ImageValueInterpreter.h>

+ Inheritance diagram for agxIO::PNGImageValueInterpreter:

Public Member Functions

 PNGImageValueInterpreter ()
 Default constructor. More...
 
 PNGImageValueInterpreter (float minValue, float maxValue)
 Construct given minimum- and maximum value. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
agxIO::Image * getImage () const
 
size_t getImageHeight () const
 
size_t getImageWidth () const
 
float getMaxValue () const
 
float getMinValue () const
 
int getReferenceCount () const
 
float getValue (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads image at pixel (x,y) and returns value between given minimum and maximum. More...
 
float getValueA (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Alpha" channel at pixel (x,y) and returns value between given minimum and maximum. More...
 
float getValueB (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Blue" channel at pixel (x,y) and returns value between given minimum and maximum. More...
 
float getValueG (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Green" channel at pixel (x,y) and returns value between given minimum and maximum. More...
 
float getValueR (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Red" channel at pixel (x,y) and returns value between given minimum and maximum. More...
 
agx::Vec3f getValueRGB (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads R, G, and B channels and returns Vec3f with result at pixel (x,y). More...
 
agx::Vec4f getValueRGBA (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads R, G, B and A channels and returns Vec4f with result at pixel (x,y). More...
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool read (const std::string &filename)
 Read PNG image. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void setMaxValue (float maxValue)
 Set new maximum value for the accessors methods (i.e., channel value = 255 => maximum value). More...
 
void setMinValue (float minValue)
 Set new minimum value for the accessors methods (i.e., channel value = 0 => minimum value). More...
 
void setValueA (unsigned char val, size_t x, size_t y)
 Set current value to the "Alpha" channel. More...
 
void setValueB (unsigned char val, size_t x, size_t y)
 Set current value to the "Blue" channel. More...
 
void setValueG (unsigned char val, size_t x, size_t y)
 Set current value to the "Green" channel. More...
 
void setValueR (unsigned char val, size_t x, size_t y)
 Set current value to the "Red" channel. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
bool valid () const
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~PNGImageValueInterpreter ()
 Reference counted object. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

agxIO::ImageRef m_image
 
float m_maxValue
 
float m_minValue
 
Mutex m_mutex
 
ObserverContainer m_observers
 
ReadValue01Function m_readFunction
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 82 of file ImageValueInterpreter.h.

Constructor & Destructor Documentation

agxIO::PNGImageValueInterpreter::PNGImageValueInterpreter ( )

Default constructor.

Minimum value set to 0 and maximum value to 1.

agxIO::PNGImageValueInterpreter::PNGImageValueInterpreter ( float  minValue,
float  maxValue 
)

Construct given minimum- and maximum value.

Parameters
minValue- minimum value when image channel value is zero
maxValue- maximum value when image channel value is 255
virtual agxIO::PNGImageValueInterpreter::~PNGImageValueInterpreter ( )
protectedvirtual

Reference counted object.

Protected destructor.

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
agxIO::Image* agxIO::PNGImageValueInterpreter::getImage ( ) const
Returns
the PNG image if initialized
size_t agxIO::PNGImageValueInterpreter::getImageHeight ( ) const
Returns
the height of the image (number of pixels)
size_t agxIO::PNGImageValueInterpreter::getImageWidth ( ) const
Returns
the width of the image (number of pixels)
float agxIO::PNGImageValueInterpreter::getMaxValue ( ) const
Returns
the maximum value used by the accessors methods (when channel value = 255)
float agxIO::PNGImageValueInterpreter::getMinValue ( ) const
Returns
the minimum value used by the accessors methods (when channel value = 0)
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
float agxIO::PNGImageValueInterpreter::getValue ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads image at pixel (x,y) and returns value between given minimum and maximum.

Alpha channel is ignored for any PNG with alpha (i.e., 2 or 4). For 3 and 4 channels the RGB channels are merged to a gray scale single value and passed to GetValueFunction func.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum
float agxIO::PNGImageValueInterpreter::getValueA ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Alpha" channel at pixel (x,y) and returns value between given minimum and maximum.

The PNG has to have either two or four channels for the value to be valid. E.g., if three channels, value of G will be calculated (offset = numChannels - 1). Asserts if number of channels is 1 or 3, but make sure you have the correct number of channels when calling this method.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum
float agxIO::PNGImageValueInterpreter::getValueB ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Blue" channel at pixel (x,y) and returns value between given minimum and maximum.

The PNG has to have at least three channels for valid calls to this method.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum
float agxIO::PNGImageValueInterpreter::getValueG ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Green" channel at pixel (x,y) and returns value between given minimum and maximum.

If the PNG has two channels, the alpha channel will be used here (i.e., same result as calling getValueA).

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum
float agxIO::PNGImageValueInterpreter::getValueR ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Red" channel at pixel (x,y) and returns value between given minimum and maximum.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum
agx::Vec3f agxIO::PNGImageValueInterpreter::getValueRGB ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads R, G, and B channels and returns Vec3f with result at pixel (x,y).

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
Vec3f with results
agx::Vec4f agxIO::PNGImageValueInterpreter::getValueRGBA ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads R, G, B and A channels and returns Vec4f with result at pixel (x,y).

I.e., the PNG has to have four channels for the values to be valid.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
Vec4f with results
template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agxIO::PNGImageValueInterpreter::read ( const std::string &  filename)

Read PNG image.

Searches agx paths.

Returns
true if load was successful - otherwise false (file not found or unsupported PNG)
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxIO::PNGImageValueInterpreter::setMaxValue ( float  maxValue)

Set new maximum value for the accessors methods (i.e., channel value = 255 => maximum value).

Parameters
maxValue- maximum value
void agxIO::PNGImageValueInterpreter::setMinValue ( float  minValue)

Set new minimum value for the accessors methods (i.e., channel value = 0 => minimum value).

Parameters
minValue- minimum value
void agxIO::PNGImageValueInterpreter::setValueA ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Alpha" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.
void agxIO::PNGImageValueInterpreter::setValueB ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Blue" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.
void agxIO::PNGImageValueInterpreter::setValueG ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Green" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.
void agxIO::PNGImageValueInterpreter::setValueR ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Red" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

bool agxIO::PNGImageValueInterpreter::valid ( ) const
Returns
true if the image is valid
template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

agxIO::ImageRef agxIO::PNGImageValueInterpreter::m_image
protected

Definition at line 246 of file ImageValueInterpreter.h.

float agxIO::PNGImageValueInterpreter::m_maxValue
protected

Definition at line 248 of file ImageValueInterpreter.h.

float agxIO::PNGImageValueInterpreter::m_minValue
protected

Definition at line 247 of file ImageValueInterpreter.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

ReadValue01Function agxIO::PNGImageValueInterpreter::m_readFunction
protected

Definition at line 249 of file ImageValueInterpreter.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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