osgEarth 2.1.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

osgEarth::ImageUtils::PixelReader Class Reference

List of all members.

Public Types

typedef osg::Vec4(* ReaderFunc )(const PixelReader *ia, int s, int t, int r, int m)

Public Member Functions

 PixelReader (const osg::Image *image)
osg::Vec4 operator() (int s, int t, int r=0, int m=0) const
const unsigned char * data (int s=0, int t=0, int r=0, int m=0) const

Static Public Member Functions

static bool supports (GLenum pixelFormat, GLenum dataType)
static bool supports (const osg::Image *image)

Public Attributes

ReaderFunc _reader
const osg::Image * _image
unsigned _colMult
unsigned _rowMult
unsigned _imageSize

Detailed Description

Reads color data out of an image, regardles of its internal pixel format.

Definition at line 202 of file ImageUtils.


Member Typedef Documentation

typedef osg::Vec4(* osgEarth::ImageUtils::PixelReader::ReaderFunc)(const PixelReader *ia, int s, int t, int r, int m)

Definition at line 227 of file ImageUtils.


Constructor & Destructor Documentation

ImageUtils::PixelReader::PixelReader ( const osg::Image *  image)

Definition at line 941 of file ImageUtils.cpp.

                                                        :
_image(image)
{
    _colMult = _image->getPixelSizeInBits() / 8;
    _rowMult = _image->getRowSizeInBytes();
    _imageSize = _image->getImageSizeInBytes();
    GLenum dataType = _image->getDataType();
    _reader = getReader( _image->getPixelFormat(), dataType );
    if ( !_reader )
    {
        OE_WARN << "[PixelReader] No reader found for pixel format " << std::hex << _image->getPixelFormat() << std::endl; 
        _reader = &ColorReader<0,GLbyte>::read;
    }
}

Here is the call graph for this function:


Member Function Documentation

const unsigned char* osgEarth::ImageUtils::PixelReader::data ( int  s = 0,
int  t = 0,
int  r = 0,
int  m = 0 
) const [inline]

Definition at line 221 of file ImageUtils.

                                                                                {
                return m == 0 ?
                    _image->data() + s*_colMult + t*_rowMult + r*_imageSize :
                    _image->getMipmapData(m) + s*_colMult + t*(_rowMult >> m) + r*(_imageSize>>m) ;
            }

Here is the caller graph for this function:

osg::Vec4 osgEarth::ImageUtils::PixelReader::operator() ( int  s,
int  t,
int  r = 0,
int  m = 0 
) const [inline]

Reads a color from the image

Definition at line 216 of file ImageUtils.

                                                                     {
                return (*_reader)(this, s, t, r, m);
            }
bool ImageUtils::PixelReader::supports ( GLenum  pixelFormat,
GLenum  dataType 
) [static]

Whether PixelReader supports a given format/datatype combiniation.

Definition at line 957 of file ImageUtils.cpp.

{
    return getReader(pixelFormat, dataType) != 0L;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool osgEarth::ImageUtils::PixelReader::supports ( const osg::Image *  image) [inline, static]

Whether PixelReader can read from the specified image.

Definition at line 211 of file ImageUtils.

                                                          {
                return image && supports(image->getPixelFormat(), image->getDataType() );
            }

Member Data Documentation

Definition at line 230 of file ImageUtils.

Definition at line 229 of file ImageUtils.

Definition at line 232 of file ImageUtils.

Definition at line 228 of file ImageUtils.

Definition at line 231 of file ImageUtils.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines