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

osgEarth::ImageUtils::PixelWriter Class Reference

List of all members.

Public Types

typedef void(* WriterFunc )(const PixelWriter *iw, const osg::Vec4 &c, int s, int t, int r, int m)

Public Member Functions

 PixelWriter (osg::Image *image)
void operator() (const osg::Vec4 &c, int s, int t, int r=0, int m=0)
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

osg::Image * _image
unsigned _colMult
unsigned _rowMult
unsigned _imageSize
WriterFunc _writer

Detailed Description

Writes color data to an image, regardles of its internal pixel format.

Definition at line 238 of file ImageUtils.


Member Typedef Documentation

typedef void(* osgEarth::ImageUtils::PixelWriter::WriterFunc)(const PixelWriter *iw, const osg::Vec4 &c, int s, int t, int r, int m)

Definition at line 268 of file ImageUtils.


Constructor & Destructor Documentation

ImageUtils::PixelWriter::PixelWriter ( osg::Image *  image)

Definition at line 1029 of file ImageUtils.cpp.

                                                  :
_image(image)
{
    _colMult = _image->getPixelSizeInBits() / 8;
    _rowMult = _image->getRowSizeInBytes();
    _imageSize = _image->getImageSizeInBytes();
    GLenum dataType = _image->getDataType();
    _writer = getWriter( _image->getPixelFormat(), dataType );
    if ( !_writer )
    {
        OE_WARN << "[PixelWriter] No writer found for pixel format " << std::hex << _image->getPixelFormat() << std::endl; 
        _writer = &ColorWriter<0, GLbyte>::write;
    }
}

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 262 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:

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

Writes a color to a pixel.

Definition at line 252 of file ImageUtils.

                                                                              {
                (*_writer)(this, c, s, t, r, m );
            }
bool ImageUtils::PixelWriter::supports ( GLenum  pixelFormat,
GLenum  dataType 
) [static]

Whether PixelWriter can write to an image with the given format/datatype combo.

Definition at line 1045 of file ImageUtils.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Whether PixelWriter can write to non-const version of an image.

Definition at line 247 of file ImageUtils.

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

Member Data Documentation

Definition at line 258 of file ImageUtils.

Definition at line 257 of file ImageUtils.

Definition at line 260 of file ImageUtils.

Definition at line 259 of file ImageUtils.

Definition at line 269 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