OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
WGEImage Class Reference

Image data object. More...

#include <WGEImage.h>

+ Collaboration diagram for WGEImage:

Public Types

enum  Origin { BOTTOM_LEFT = 0 , TOP_LEFT }
 Where is the origin? More...
 
typedef std::shared_ptr< WGEImageSPtr
 Convenience typedef for a std::shared_ptr< WGEImage >. More...
 
typedef std::shared_ptr< const WGEImageConstSPtr
 Convenience typedef for a std::shared_ptr< const WGEImage >. More...
 

Public Member Functions

 WGEImage ()
 Default constructor. More...
 
 WGEImage (const osg::Image &image)
 Construct from a given osg::Image. More...
 
 WGEImage (const WGEImage &image)
 Copy construct from given image. More...
 
virtual ~WGEImage ()
 Destructor. More...
 
WGEImageoperator= (WGEImage other)
 Copy assignment operator. More...
 
int getWidth () const
 Get size in X direction. More...
 
int getHeight () const
 Get size in Y direction. More...
 
int getDepth () const
 Get size in Z direction. More...
 
osg::ref_ptr< osg::Image > getAsOSGImage () const
 Return the underlying osg::Image. More...
 
unsigned char * data ()
 Get the raw image data. More...
 
const unsigned char * data () const
 Get the raw image data. More...
 
WColor getColor (unsigned int x, unsigned int y=0, unsigned int z=0)
 Grab color at specified pixel/voxel. More...
 
Origin getOrigin () const
 Query origin. More...
 

Static Public Member Functions

static WGEImage::SPtr createFromFile (boost::filesystem::path file)
 Load an image from a file. More...
 
static WGEImage::SPtr createFromFile (std::string file)
 Load an image from a file. More...
 

Private Attributes

osg::ref_ptr< osg::Image > m_image
 The osg image we use. More...
 

Detailed Description

Image data object.

Encapsulate 1D, 2D, and 3D images. Also provides static load function. This basically encapsulates an osg::Image. The osg::Image can contain a huge variety of image data of different data types, formats, and so on.

Note
If the API of WGEImage is not sufficient, you can use getAsOSGImage() and use theirs.

Definition at line 42 of file WGEImage.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WGEImage > WGEImage::ConstSPtr

Convenience typedef for a std::shared_ptr< const WGEImage >.

Definition at line 53 of file WGEImage.h.

◆ SPtr

typedef std::shared_ptr< WGEImage > WGEImage::SPtr

Convenience typedef for a std::shared_ptr< WGEImage >.

Definition at line 48 of file WGEImage.h.

Member Enumeration Documentation

◆ Origin

Where is the origin?

Enumerator
BOTTOM_LEFT 

bottom left origin

TOP_LEFT 

top left origin

Definition at line 162 of file WGEImage.h.

Constructor & Destructor Documentation

◆ WGEImage() [1/3]

WGEImage::WGEImage ( )

Default constructor.

Definition at line 34 of file WGEImage.cpp.

Referenced by createFromFile().

+ Here is the caller graph for this function:

◆ WGEImage() [2/3]

WGEImage::WGEImage ( const osg::Image &  image)
explicit

Construct from a given osg::Image.

Parameters
imagethe image

Definition at line 40 of file WGEImage.cpp.

◆ WGEImage() [3/3]

WGEImage::WGEImage ( const WGEImage image)
explicit

Copy construct from given image.

Parameters
imagethe image

Definition at line 45 of file WGEImage.cpp.

◆ ~WGEImage()

WGEImage::~WGEImage ( )
virtual

Destructor.

Definition at line 56 of file WGEImage.cpp.

Member Function Documentation

◆ createFromFile() [1/2]

WGEImage::SPtr WGEImage::createFromFile ( boost::filesystem::path  file)
static

Load an image from a file.

This is very fault tolerant. Just returns NULL on error.

Parameters
filethe file to load
Returns
the image. Can be NULL on error.

Definition at line 80 of file WGEImage.cpp.

Referenced by WMTemplateShaders::moduleMain(), and WMTemplateUI::moduleMain().

+ Here is the caller graph for this function:

◆ createFromFile() [2/2]

WGEImage::SPtr WGEImage::createFromFile ( std::string  file)
static

Load an image from a file.

This is very fault tolerant. Just returns NULL on error.

Parameters
filethe file to load
Returns
the image. Can be NULL on error.

Definition at line 61 of file WGEImage.cpp.

References wlog::error(), and WGEImage().

+ Here is the call graph for this function:

◆ data() [1/2]

unsigned char * WGEImage::data ( )

Get the raw image data.

Returns
the raw data.

Definition at line 105 of file WGEImage.cpp.

References m_image.

◆ data() [2/2]

const unsigned char * WGEImage::data ( ) const

Get the raw image data.

Returns
the raw data.

Definition at line 110 of file WGEImage.cpp.

References m_image.

◆ getAsOSGImage()

osg::ref_ptr< osg::Image > WGEImage::getAsOSGImage ( ) const

Return the underlying osg::Image.

Should rarely be used and is mostly useful when working directly with OSG.

Returns
the osg::Image instance

Definition at line 85 of file WGEImage.cpp.

References m_image.

◆ getColor()

WColor WGEImage::getColor ( unsigned int  x,
unsigned int  y = 0,
unsigned int  z = 0 
)

Grab color at specified pixel/voxel.

Please note that you should consider the image's origin. Query with getOrigin().

Parameters
xX coord
yY coord, optional in 1D images
zZ coord, optional in 1D,2D images.
Returns
color at given position

Definition at line 115 of file WGEImage.cpp.

References m_image.

◆ getDepth()

int WGEImage::getDepth ( ) const

Get size in Z direction.

This is 1 for 2D & 1D images.

Returns
the depth

Definition at line 100 of file WGEImage.cpp.

References m_image.

◆ getHeight()

int WGEImage::getHeight ( ) const

Get size in Y direction.

This is 1 for 1D images.

Returns
the height

Definition at line 95 of file WGEImage.cpp.

References m_image.

◆ getOrigin()

WGEImage::Origin WGEImage::getOrigin ( ) const

Query origin.

Returns
the origin.

Definition at line 120 of file WGEImage.cpp.

References BOTTOM_LEFT, m_image, and TOP_LEFT.

◆ getWidth()

int WGEImage::getWidth ( ) const

Get size in X direction.

Returns
the width

Definition at line 90 of file WGEImage.cpp.

References m_image.

◆ operator=()

WGEImage & WGEImage::operator= ( WGEImage  other)

Copy assignment operator.

Parameters
otherthe other instance
Returns
this

Definition at line 50 of file WGEImage.cpp.

References m_image.

Member Data Documentation

◆ m_image

osg::ref_ptr< osg::Image > WGEImage::m_image
private

The osg image we use.

Definition at line 179 of file WGEImage.h.

Referenced by data(), getAsOSGImage(), getColor(), getDepth(), getHeight(), getOrigin(), getWidth(), and operator=().


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