Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

osg::Image Class Reference

Image class for encapsulating the storage texture image data. More...

Inheritance diagram for osg::Image:

Inheritance graph
[legend]
List of all members.

Public Types

typedef std::vector< unsigned
int > 
MipmapDataType

Public Methods

 Image ()
 Image (const Image &image, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 Copy constructor using CopyOp to manage deep vs shallow copy.

virtual ObjectcloneType () const
 Clone the type of an object, with Object* return type.

virtual Objectclone (const CopyOp &copyop) const
 Clone the an object, with Object* return type.

virtual bool isSameKindAs (const Object *obj) const
virtual const char * libraryName () const
 return the name of the object's library.

virtual const char * className () const
 return the name of the object's class type.

void setFileName (const std::string &fileName)
const std::string & getFileName () const
void allocateImage (int s, int t, int r, GLenum format, GLenum type, int packing=1)
void setImage (int s, int t, int r, GLint internalTextureformat, GLenum format, GLenum type, unsigned char *data, int packing=1)
 set the image data and format.

void readPixels (int x, int y, int width, int height, GLenum format, GLenum type)
 readPixels from screen at specified position and size, using glReadPixels.

void scaleImage (const int s, const int t, const int r)
 Scale image to specified size.

void copySubImage (int s_offset, int t_offset, int r_offset, osg::Image *source)
 Copy a source Image into a subpart of this Image at specified position.

const int s () const
 Width of image.

const int t () const
 Height of image.

const int r () const
 Depth of image.

void setInternalTextureFormat (GLint internalFormat)
const GLint getInternalTextureFormat () const
void setPixelFormat (const GLenum format)
const GLenum getPixelFormat () const
const GLenum getDataType () const
const unsigned int getPacking () const
const unsigned int getPixelSizeInBits () const
 return the numbers of bits required for each pixel.

const unsigned int getRowSizeInBytes () const
 return the numbers of bytes each row of pixels occupies once it has been packed.

const unsigned int getImageSizeInBytes () const
 return the numbers of bytes each image (_s*_t) of pixels occupies..

const unsigned int getTotalSizeInBytes () const
 return the numbers of bytes the whole row/image/volume of pixels occupies.

unsigned char * data ()
 raw image data.

const unsigned char * data () const
 raw const image data.

unsigned char * data (int column, int row=0, int image=0)
const unsigned char * data (int column, int row=0, int image=0) const
void flipHorizontal (int image=0)
 Flip the image horizontally.

void flipVertical (int image=0)
 Flip the image vertically.

void ensureValidSizeForTexturing ()
 Ensure image dimensions are a power of two.

void dirty ()
 Dirty the image, which increments the modified flag, to force osg::Texture to reload the image.

void setModifiedTag (const unsigned int value)
 Set the modified tag value, only used by osg::Texture when using texture subloading.

const unsigned int getModifiedTag () const
 Get modified tag value, only used by osg::Texture when using texture subloading.

bool isMipmap () const
unsigned int getNumMipmapLevels () const
void setMipmapData (const MipmapDataType &mipmapDataVector)
unsigned char * getMipmapData (unsigned int mipmapNumber) const
void computeMipMaps ()
 converts a single image into mip mapped version image.


Static Public Methods

const bool isPackedType (GLenum type)
const unsigned int computeNumComponents (GLenum format)
const unsigned int computePixelSizeInBits (GLenum format, GLenum type)
const unsigned int computeRowWidthInBytes (int width, GLenum format, GLenum type, int packing)
const unsigned int computeNearestPowerOfTwo (unsigned int s, float bias=0.5f)

Protected Methods

virtual ~Image ()
Image & operator= (const Image &)

Protected Attributes

std::string _fileName
int _s
int _t
int _r
GLint _internalTextureFormat
GLenum _pixelFormat
GLenum _dataType
unsigned int _packing
unsigned char * _data
unsigned int _modifiedTag
MipmapDataType _mipmapData

Detailed Description

Image class for encapsulating the storage texture image data.


Member Typedef Documentation

typedef std::vector< unsigned int > osg::Image::MipmapDataType
 


Constructor & Destructor Documentation

osg::Image::Image  
 

osg::Image::Image const Image &    image,
const CopyOp   copyop = CopyOp::SHALLOW_COPY
 

Copy constructor using CopyOp to manage deep vs shallow copy.

virtual osg::Image::~Image   [protected, virtual]
 


Member Function Documentation

void osg::Image::allocateImage int    s,
int    t,
int    r,
GLenum    format,
GLenum    type,
int    packing = 1
 

virtual const char* osg::Image::className   const [inline, virtual]
 

return the name of the object's class type.

Must be defined by derived classes.

Implements osg::Object.

virtual Object* osg::Image::clone const CopyOp   copyop const [inline, virtual]
 

Clone the an object, with Object* return type.

Must be defined by derived classes.

Implements osg::Object.

virtual Object* osg::Image::cloneType   const [inline, virtual]
 

Clone the type of an object, with Object* return type.

Must be defined by derived classes.

Implements osg::Object.

void osg::Image::computeMipMaps  
 

converts a single image into mip mapped version image.

const unsigned int osg::Image::computeNearestPowerOfTwo unsigned int    s,
float    bias = 0.5f
[static]
 

const unsigned int osg::Image::computeNumComponents GLenum    format [static]
 

const unsigned int osg::Image::computePixelSizeInBits GLenum    format,
GLenum    type
[static]
 

const unsigned int osg::Image::computeRowWidthInBytes int    width,
GLenum    format,
GLenum    type,
int    packing
[static]
 

void osg::Image::copySubImage int    s_offset,
int    t_offset,
int    r_offset,
osg::Image *    source
 

Copy a source Image into a subpart of this Image at specified position.

Typically used to copy to an already allocated image, such as creating a 3D image from a stack 2D images. If the this Image is empty then image data is created to accomodate the imaging image in its offset position. If source is NULL then no operation happens, this Image is left unchanged.

const unsigned char* osg::Image::data int    column,
int    row = 0,
int    image = 0
const [inline]
 

unsigned char* osg::Image::data int    column,
int    row = 0,
int    image = 0
[inline]
 

const unsigned char* osg::Image::data   const [inline]
 

raw const image data.

unsigned char* osg::Image::data   [inline]
 

raw image data.

void osg::Image::dirty   [inline]
 

Dirty the image, which increments the modified flag, to force osg::Texture to reload the image.

void osg::Image::ensureValidSizeForTexturing  
 

Ensure image dimensions are a power of two.

Mip Mapped texture require the image dimensions to be power of two and are within the maxiumum texture size for the host machine.

void osg::Image::flipHorizontal int    image = 0
 

Flip the image horizontally.

void osg::Image::flipVertical int    image = 0
 

Flip the image vertically.

const GLenum osg::Image::getDataType   const [inline]
 

const std::string& osg::Image::getFileName   const [inline]
 

const unsigned int osg::Image::getImageSizeInBytes   const [inline]
 

return the numbers of bytes each image (_s*_t) of pixels occupies..

const GLint osg::Image::getInternalTextureFormat   const [inline]
 

unsigned char* osg::Image::getMipmapData unsigned int    mipmapNumber const [inline]
 

const unsigned int osg::Image::getModifiedTag   const [inline]
 

Get modified tag value, only used by osg::Texture when using texture subloading.

unsigned int osg::Image::getNumMipmapLevels   const [inline]
 

const unsigned int osg::Image::getPacking   const [inline]
 

const GLenum osg::Image::getPixelFormat   const [inline]
 

const unsigned int osg::Image::getPixelSizeInBits   const [inline]
 

return the numbers of bits required for each pixel.

const unsigned int osg::Image::getRowSizeInBytes   const [inline]
 

return the numbers of bytes each row of pixels occupies once it has been packed.

const unsigned int osg::Image::getTotalSizeInBytes   const [inline]
 

return the numbers of bytes the whole row/image/volume of pixels occupies.

bool osg::Image::isMipmap   const [inline]
 

const bool osg::Image::isPackedType GLenum    type [static]
 

virtual bool osg::Image::isSameKindAs const Object   obj const [inline, virtual]
 

Reimplemented from osg::Object.

virtual const char* osg::Image::libraryName   const [inline, virtual]
 

return the name of the object's library.

Must be defined by derived classes. The OpenSceneGraph convention the is that the namspace of a library is the same as the library name.

Implements osg::Object.

Image& osg::Image::operator= const Image &    [inline, protected]
 

const int osg::Image::r   const [inline]
 

Depth of image.

void osg::Image::readPixels int    x,
int    y,
int    width,
int    height,
GLenum    format,
GLenum    type
 

readPixels from screen at specified position and size, using glReadPixels.

Create memory for storage if required, reuse existing pixel coords if possible. if pixelFormat or dataType

const int osg::Image::s   const [inline]
 

Width of image.

void osg::Image::scaleImage const int    s,
const int    t,
const int    r
 

Scale image to specified size.

void osg::Image::setFileName const std::string &    fileName
 

void osg::Image::setImage int    s,
int    t,
int    r,
GLint    internalTextureformat,
GLenum    format,
GLenum    type,
unsigned char *    data,
int    packing = 1
 

set the image data and format.

note, when the packing value is negative (the default is -1) this method assumes a _packing width of 1 if the width is not a multiple of 4, otherwise automatically sets to _packing to 4. If a positive value of packing is supplied than _packing is simply set to that value.

void osg::Image::setInternalTextureFormat GLint    internalFormat
 

void osg::Image::setMipmapData const MipmapDataType   mipmapDataVector [inline]
 

void osg::Image::setModifiedTag const unsigned int    value [inline]
 

Set the modified tag value, only used by osg::Texture when using texture subloading.

void osg::Image::setPixelFormat const GLenum    format
 

const int osg::Image::t   const [inline]
 

Height of image.


Member Data Documentation

unsigned char* osg::Image::_data [protected]
 

GLenum osg::Image::_dataType [protected]
 

std::string osg::Image::_fileName [protected]
 

GLint osg::Image::_internalTextureFormat [protected]
 

MipmapDataType osg::Image::_mipmapData [protected]
 

unsigned int osg::Image::_modifiedTag [protected]
 

unsigned int osg::Image::_packing [protected]
 

GLenum osg::Image::_pixelFormat [protected]
 

int osg::Image::_r [protected]
 

int osg::Image::_s [protected]
 

int osg::Image::_t [protected]
 


The documentation for this class was generated from the following file:
Generated at Wed Sep 18 13:55:31 2002 for the Open Scene Graph by doxygen 1.2.16.