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

osgEarth::ImageMosaic Class Reference

Inheritance diagram for osgEarth::ImageMosaic:
Collaboration diagram for osgEarth::ImageMosaic:

List of all members.

Public Types

typedef std::vector< TileImageTileImageList

Public Member Functions

 ImageMosaic ()
osg::Image * createImage ()
TileImageListgetImages ()
void getExtents (double &minX, double &minY, double &maxX, double &maxY)

Protected Member Functions

 ~ImageMosaic ()

Protected Attributes

TileImageList _images

Detailed Description

Utility class for extracting a single image from a collection of image tiles

Definition at line 58 of file ImageMosaic.


Member Typedef Documentation

A list of GeoImages

Definition at line 66 of file ImageMosaic.


Constructor & Destructor Documentation

ImageMosaic::ImageMosaic ( )

Definition at line 42 of file ImageMosaic.cpp.

{
}
ImageMosaic::~ImageMosaic ( ) [protected]

Definition at line 46 of file ImageMosaic.cpp.

{
}

Member Function Documentation

osg::Image * ImageMosaic::createImage ( )

Definition at line 67 of file ImageMosaic.cpp.

{
    if (_images.size() == 0)
    {
        OE_NOTICE << "ImageMosaic has no images..." << std::endl;
        return 0;
    }

    unsigned int tileWidth = _images[0]._image->s();
    unsigned int tileHeight = _images[0]._image->t();

    //OE_NOTICE << "TileDim " << tileWidth << ", " << tileHeight << std::endl;

    unsigned int minTileX = _images[0]._tileX;
    unsigned int minTileY = _images[0]._tileY;
    unsigned int maxTileX = _images[0]._tileX;
    unsigned int maxTileY = _images[0]._tileY;

    //Compute the tile size.
    for (TileImageList::iterator i = _images.begin(); i != _images.end(); ++i)
    {
        if (i->_tileX < minTileX) minTileX = i->_tileX;
        if (i->_tileY < minTileY) minTileY = i->_tileY;

        if (i->_tileX > maxTileX) maxTileX = i->_tileX;
        if (i->_tileY > maxTileY) maxTileY = i->_tileY;
    }

    unsigned int tilesWide = maxTileX - minTileX + 1;
    unsigned int tilesHigh = maxTileY - minTileY + 1;

    unsigned int pixelsWide = tilesWide * tileWidth;
    unsigned int pixelsHigh = tilesHigh * tileHeight;

    osg::ref_ptr<osg::Image> image = new osg::Image;
    image->allocateImage(pixelsWide, pixelsHigh, 1, _images[0]._image->getPixelFormat(), _images[0]._image->getDataType());
    image->setInternalTextureFormat(_images[0]._image->getInternalTextureFormat()); 

    //Composite the incoming images into the master image
    for (TileImageList::iterator i = _images.begin(); i != _images.end(); ++i)
    {
        //Determine the indices in the master image for this image
        int dstX = (i->_tileX - minTileX) * tileWidth;
        int dstY = (maxTileY - i->_tileY) * tileHeight;
        ImageUtils::copyAsSubImage(i->getImage(), image.get(), dstX, dstY);
    }

    return image.release();
}

Here is the call graph for this function:

void ImageMosaic::getExtents ( double &  minX,
double &  minY,
double &  maxX,
double &  maxY 
)

Definition at line 50 of file ImageMosaic.cpp.

{
    minX = DBL_MAX;
    maxX = -DBL_MAX;
    minY = DBL_MAX;
    maxY = -DBL_MAX;

    for (TileImageList::iterator i = _images.begin(); i != _images.end(); ++i)
    {
        minX = osg::minimum(i->_minX, minX);
        minY = osg::minimum(i->_minY, minY);
        maxX = osg::maximum(i->_maxX, maxX);
        maxY = osg::maximum(i->_maxY, maxY);
    }
}
TileImageList& osgEarth::ImageMosaic::getImages ( ) [inline]

Gets the images for this ImageMosaic

Definition at line 69 of file ImageMosaic.

{return _images;}

Member Data Documentation

Definition at line 76 of file ImageMosaic.


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